Examples of Using Wildcards
Some examples of using wildcard characters in queries are the following:
- the wildcard query 'f?rm' will match all of the words 'farm', 'firm', and 'form' - any word that begins with an 'f', is followed by any other character, and ends with the characters 'rm'.
- the wildcard query '??rm' will match all of the words in the previous bullet, as well as words like 'harm', 'term', 'worm', and so on - any four character word that ends with the characters 'rm'.
- the wildcard query '??ow*rm' will match terms such as 'glowworm', 'slowworm', and 'snowstorm' - any word that begins with any two characters, followed by the character sequence 'ow', followed by any number of other characters, and ending in the character sequence 'rm'.
- the wildcard query '*rm' will match all of the words in the previous bullets, as well as words like 'alarm', 'bookworm', 'brainstorm', 'terraform', 'wheatgerm', and so on. Because the '*' wildcard character can represent any sequence composed of any characters, the expression '*rm' matches any term that ends in 'rm'. Matching terms would also include the Linux command 'rm', because the wildcard '*' can also match zero characters. The regular expression '?rm' would not match the Linux command 'rm', because the '?' wildcard operator must match a character in the specified position.
As these examples show, wildcards provide a very flexible mechanism for searching for words or phrases that match a given pattern. Some general rules about using wildcards in Watson™ Explorer Engine searches are the following:
- The '?' wildcard matches any single UTF-8 symbol, not just a single byte. For example, the query '?iv?simo' would match the terms 'Vivisimo', 'vivisimo', 'Vivísimo', and 'vivísimo'.
- Wildcard expressions can appear in phrases ("viv?simo cluster*"), but will not span terms in a phrase. For example, 'viv?simo cluster*' will match 'vivisimo cluster', but 'v*r' will not.
- Wildcards may be combined with standard Watson Explorer Engine search syntax. For example 'f??' OR 'b??' will match results containing 'foo', 'bar', 'baz', and so on.