Example 5
Return to Introduction  Previous page  Next page
Suppose you wanted to search for GetDefault() followed by any number of spaces then a plus sign and some more spaces and then a double quote and a backslash.

Breaking this into its components we want to search for:

n GetDefault()
n zero or more spaces
n +
n zero or more spaces
n "\

Now before we try to turn this into a regular expression we need to note that the brackets, plus sign and backslash are characters with special meaning in regular expressions, so in order to treat them as literal characters we have to "escape" them by preceding them with a backslash. So to search for GetDefault() in a regular expression we need to use GetDefault\(\). Zero or more spaces can be matched by putting in a space character followed by an asterisk. To get the literal plus sign we need to use \+. And finally to get the double quote and the backslash (which we need to escape) we use "\\.

So the final search regular expression is:

GetDefault\(\) *\+ *"\\

and it will match all of the following:

GetDefault()+"\O*.DBF"
GetDefault() + "\O*.DBF"
GetDefault()        +               "\O*.DBF"



Once matched you could use a replace string such as

GetDefault() + "

to remove the trailing backslash from the search expression (if that's what you want to do).



© Piko Computing Consultants, 1998-2002