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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding text lowercase or uppercase

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
hallo,
I would need to replace a string in another string. The problem is that I would like the replace function to be case insensitive. Do you have a suggestion for this? thanks
 

string TargetString; // We replace here
string key; // replace what
string NewKey; // replace with this

We will find the position ot which the string is, remove the old and add a new one. But to be case sensitive we will search when both strings are in Lower


int pos =targ.ToLower().IndexOf(key.ToLower);
// if there is a match
if (pos <>-1 )
{
// remove old
targ.Remove(pos,key.Length);
// add the newkey
targ.Insert(pos,Newkey);
}

I just forgot the pos function and I am not sure weather pos returns 0 or -1 if sub string is not found.

Good Luck
 
try RegEx:
<script runat="Server">
sub Page_Load
Dim StringToFind="ASD"
Dim RegExp as new RegEx(StringToFind,1)
Dim TestString as string="asd"
response.write("Test string is -")
response.write(RegExp.replace(TestString,""))
end sub
</script>


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top