Link to home
Start Free TrialLog in
Avatar of sunny-j
sunny-j

asked on

help with regular expressions

Need some help with matching a word using regular expressions. this below is not matching.  Any help appreciated.

I am looking to match either
"Band:"
or
Band:
 

var pagesStr = content.GetElementsByTagName("SPAN")[18].InnerHtml;
                                    if (content != null && Regex.IsMatch(pagesStr, @"\^\[Band:\]\+\$"))
                                    {
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Try it like this
Regex.IsMatch(pagesStr, @"\""?[Band:]+\""?")

Open in new window

Though Fernando's pattern may work just fine, it will also match other values containing the characters in Band: such as BBBB or Bad:

I suggest making this modification if you need the exact string Band:
Regex.IsMatch(pagesStr, @"\""?Band:\""?")

Open in new window


Note that will still match if there is just one double quote (or none, or one at each end). If that's a problem, let us know.
ASKER CERTIFIED SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunny-j
sunny-j

ASKER

thank you both for your input and apologies for my delay in responding.