You need to forget MSWord's interpretation of a regular expression and learn Perl's.
^ : begin of line
$ : end of line
[] : character class (ie, [\w])
[^] : negated character class (ie, [^\w])
. : match any character once (excludes whitespace)
? : the match is optional (ie, 'x?', or '(\w+)?')
() : grouping (ie, '(\w+)')
+ : one or more times (greedy if not used properly)
* : zero or more times (greedy if not used properly)
(?) : grouping, non-greedy (ie, 'x(\w+?)x')
| : or (ie, 'this|that')
character classes:
\d : digits (0 - 9)
\D : non-digits (same as [^\d])
\w : word character (0 - 9, a -z, _)
\W : non-word character (same as [^\w])
\s : white space (spaces, tabs, etc.; excludes '\n' by default)
\n : new line
(there are others)
special variables:
any grouped match will be assigned a special variable, numbered begining with '1'. To reference a match while inside in the regexp pattern match, use '\1' for the first match, '\2' for the second, and so on. If you are in a search and replace, then in the 'replace' part, you must use '$1' and '$2', and so on. References to these matches outside of the regexp must be in the second for mentioned. You cannot modify these variabls, or manually assign 'numbered' variabls; you must do "$match1 = $1;", etc.
There are quite a bit more things to say about regex'es in Perl, but you should do some reading in the 'perlre' man page for a better understanding.
Happy coding,
--Drew
http://www.camelsoup.com
ftp://ftp.camelsoup.com