kd,
What does this pattern mean to vb.net?
The pattern itself is a special language the RegEx understands. It has a
number of operators that mean special things.
For example:
| is alternation
() are grouping
$ is end of line
^ is beginning of line
+ is one or more
\W is non-word characters
...
For a complete list & meanings of all the operators see the reference &
documentation links below.
NOTE: Rather then
Dim pattern As String = "(^|\W+)(" & String.Join("|", words) &
")($|\W+)"
It appears you can reduce the expression to
Dim pattern As String = "(" & String.Join("|", words) & ")\b"
The \b specifies that the match must occur on a boundary between \w
(alphanumeric) & \W (nonalhpanumeric) characters.
The "Easiest" way to find out what it means is to use the Analyzer button in
Expresso or the Interpret button in RegEx Workbench (links below).
It says that it needs match the begging of the string or white space,
followed by one of the words, followed by end of the string or white space.
The begin or end of string can be a new line based on the options passed to
RegEx.
Expresso & RegEx Workbench both have wizards of varying degrees to help you
build your expression, plus they allow you to test your expressions, also
the analyzer/interpreter in each is rather handy.
Expresso:
http://www.ultrapico.com/Expresso.htm
RegEx Workbench:
http://www.gotdotnet.com/Community/...pleGuid=c712f2df-b026-4d58-8961-4ee2729d7322A
tutorial & reference on using regular expressions:
http://www.regular-expressions.info/
The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/d...l/cpconRegularExpressionsLanguageElements.asp
Hope this helps
Jay