Regular Expression Excluding Exact String

  • Thread starter Thread starter Ross Ylitalo
  • Start date Start date
R

Ross Ylitalo

I have been trying to put together a regular expression that will trap any
string with the exact string "&#" (without the quotes) and have been having
no luck.

Can anyone tell me if this is possible or not? Even better, can anyone show
the regular expression I am looking for?

Thank you,

Ross Ylitalo
(e-mail address removed)
 
If I understand you, you are looking to find any string that contains
"&#"

e.g.
"&#"
"&#abc"
"abc&#"
"abc&#abc"

Where "abc" can be any characters.

Regex-wise you might try

.*[&][#].*

but unless you have an overriding need to use regular expressions, you
might try the string function IndexOf()

e.g.

Dim str as string = "abc&#abc"
MessageBox.Show(str.IndexOf("&#"))


If found, IndexOf() returns the 0-based index of the first char (i.e. 3
in the above example) or -1 if not found.


hth,
Alan.
 
Back
Top