Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String.Replace is case sensitive... 1

Status
Not open for further replies.

sqlsamurai

Programmer
May 11, 2005
120
US
Can I do a case insensitive replace using String.Replace? Is there a better way?
 
This is a job for....Regular Expressions!

Dim regx As System.Text.RegularExpressions.Regex
Dim s As String
Dim s2 As String

s = "this is The test string. This is THE test string."

s2 = regx.Replace(s, "the", "a", System.Text.RegularExpressions.RegexOptions.IgnoreCase)

MsgBox(s2)

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Thanks jebenson! I just posted another question about regular expressions... think you could take a peak. ;-) [2thumbsup]
 
You could also use the ToUpper or ToLower methods before doing your replace...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
You're right ca8msm I could but I want to preserve the case of the text. Thanks for the sugg though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top