Wild Cards


[Find dialog in Visual FoxPro] Visual FoxPro 8 has given us better facilities for searching through code. The Find dialog in the VFP8 editor has a new tick box labelled 'Use wildcards'. You are probably already familiar with using the '?' and '*' wild cards to match one character or many characters but FoxPro 8 now goes further than this.

If you tick the wildcards box then you can still use the familiar '?' and '*' codes in your search but you are also able to use a few more from the world of regular expressions. Fox does not implement all the features of regular expressions but the following selection of codes are still going to be very useful.

Wild Cards

Wild card Matches
? any single character except a NewLine.
* any number of characters - even zero.
# a single digit.
< the start of a word.
> the end of a word.
[] a group of characters.

Examples

Example Matches
a?e 'are', 'database', 'A/e',
8?7 '1817', '8a7', and 'B48 7PQ' - remember that a space counts as a character.
a*e 'Alvechurch', 'database', and 'Mary had a little lamb' because * matches any number of characters - including one.
8*7 'SER#83/3471a', '1817', and '87' because * matches any number of characters - including no characters at all.
B## postcodes from 'B10' to 'B49' but not 'B1' because the expression specifies two digits and 'B1' has just a single digit.
<B any word starting with 'B' or 'b'.
#> any expression ending with a digit.

Groups

You can group characters together inside square brackets and search for an expression matching any one of these characters. A '!' before the group searches for any expression except one of the grouped characters.

Example Matches
[a-m] any character between 'a' and 'm' inclusive.
[123] any character matching '1', '2', or '3'.
[a-m].> any sentence ending with the letters 'a' to 'm' inclusive.
[!a-z].> any sentence ending with a non-alphabetical character.