Link to home
Start Free TrialLog in
Avatar of RayT
RayTFlag for United States of America

asked on

Case-Insensitive Search

How do I make the following work?  I want match.Success to be True regardless of the case.  If the testString = "AAA" or testString = "aAa"  

dim testString as string = "AAa"

Dim match As Match = Regex.Match(testString , "([\s\S])\1\1")
Avatar of Rgonzo1971
Rgonzo1971

Hi,


Why not?
(?i)

refer to
http://www.regular-expressions.info/modifiers.html

Regards
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany 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 RayT

ASKER

Why is the regex completely wrong?  Are you saying this is not valid? I thought \s\S is the same as .
ASKER CERTIFIED SOLUTION
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 RayT

ASKER

Yes.  That's what I am trying to do.
Avatar of RayT

ASKER

Sorry,  how do I modify the following to do just that?

Dim match As Match = Regex.Match(testString , "(.)\1\1")
Avatar of RayT

ASKER

I solve my problem with the following solution:

Dim match As Match = Regex.Match(testString.ToLower() , "(.)\1\1")
Dim match As Match = Regex.Match(testString, "(?i)(.)\1\1")
should do also.
Avatar of RayT

ASKER

Thanks!  It does indeed.