This topic is locked

Reguardless of case

11/17/2005 11:08:59 AM
ASPRunnerPro General questions
author

Simple question fer ya.
I was wondering if there is a way to use the replace function to replace a substring within a string reguardless of case? Using the Instr, Mid, and Len functions its easy, but getting a lot of substrings out of a huge piece of text is slower than using the replace function.
Not that its a big deal it just seems that the ladder takes a bit longer crunch it and spit it out...
Language filter @ http://g.1asphost.com/killgorack/maps/discussion/default.asp

RawText = LCase(Request.Form("PostBody"))



RF.MoveFirst



For ScanWords = 1 To RF.RecordCount

FilterString = RF.Fields("FilterString") 'The unwanted content (all lowercase)

StringSubject = RF.Fields("StringSubject") 'Language, Code, or smiley info

ReplaceWith = RF.Fields("ReplaceWith")'what is replaced by the unwanted code



Do While Instr(1, RawText, FilterString) <> 0

RawText = Replace(RawText, FilterString, ReplaceWith)

Loop

RF.MoveNext

Next


Without converting case on both ends I miss stuff that doesnt match in repsect to case.

Sergey Kornilov admin 11/17/2005

You need to use textual comparison mode.

RawText = Replace(RawText, FilterString, ReplaceWith, 1, -1, 1)


Also you do not need to use WHILE loop - Replace function replaces all occuriencies of search string.
More info: http://msdn.microsoft.com/library/default....sfctreplace.asp

500384 11/17/2005

why thank you!

500385 11/18/2005

That worked swimmingly!