Is there any command in vb.net like the Inlist function of foxpro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I found the 'Inlist' function of foxpro very useful.

Is there any command in vb.net that does the same job?

Thanks.
kd
 
Kd,
In addition to Herfried's link, I would suggest you review the "Complete
Thread" link in the header (of Herfried's link), as my other post in that
thread provided a number of alternatives.

Hope this helps
Jay
 
Jay,

Reading through the complete thread has been helpful. Thanks.

I have one question; may sound elementary though.

What does this pattern mean to vb.net?
Dim pattern As String = "(^|\W+)(" & String.Join("|", words) &
")($|\W+)"

At runtime, pattern would hold the value
(^|\W+)(cat|dog|sleep)($|\W+)
which is passed to
System.Text.RegularExpressions.Regex.IsMatch
How does this pattern convey to IsMatch to look for whole words, instead of
searching for a part of the pattern? Does the pattern convey to Ismatch that
“|†is a delimiter?

Regards,
kd.
 
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
 
Back
Top