PC Review


Reply
Thread Tools Rate Thread

Case-Insensitive Replace

 
 
Raterus
Guest
Posts: n/a
 
      18th May 2004
Howdy,

I'm making a search engine for an application I'm working on. I want to "bold" keywords they have searched for. I have a long string of words that represents a particular document, and I need to find out how to do a replace on this string, but have it be case-insensitive.
For instance:

dim docWords as string = "BLAH blah BlaH!"
dim myString as string = "blah"
docWords = docWords.Replace(myString, "<b>" & myString & "</b>")

My end result would be:
"<b>BLAH</b> <b>blah</b> <b>BlaH</b>!"

Right now, naturally, I only get this
"BLAH <b>blah</b> BlaH!"

I think may have to use Regex.Replace somehow, but I'm unsure how to proceed with that in order to make the search expression case insensitive. I really don't want to mess with the myString parameter too much as these words can be ever changing

I've tried using .tolower functions, which works great, but when it comes to displaying the result, everything is lowercase.

Any help would be great!!
--Michael
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Z2I=?=
Guest
Posts: n/a
 
      18th May 2004
Try this

dim docWords as string = "BLAH blah BlaH!
dim myString as string = "blah
docWords = Replace(docWords, myString, "<b>" & myString & "</b>", 1, ,CompareMethod.Text

Hope this help


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Case insensitive replace function - not working quite how I'd likeit Kevin Blount Microsoft C# .NET 0 18th Oct 2006 03:40 PM
Case-Insensitive String Replace INeedADip Microsoft C# .NET 4 28th Jun 2006 10:56 PM
Case Insensitive Search with Sensitive Replace ericswebber@gmail.com Microsoft C# .NET 1 4th May 2006 01:56 PM
how to case select with case-insensitive string ? Tee Microsoft VB .NET 3 23rd Jun 2004 08:40 PM
case insensitive replace Mark Microsoft Dot NET Framework 2 27th Sep 2003 03:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:29 AM.