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

String Function to replace [ ]

Status
Not open for further replies.

seanybravo

IS-IT--Management
Sep 24, 2003
89
GB
I have to create a function to put escape characters in to make an SQL query to work for example Sean[0] has to be preseted Sean[[]0[]] to work.

I am having problems getting my string convert funtion to work with Replace does anyone have any ideas on how to do this. I just cant seam to get my head around string manipulation. I am using ASP VBScript.

Thanks for any suggestions.
 
Basic idea is to avoid explosion of square brackets.
[tt]
s="Sean[0]"
s=replace(s,"[","<[>")
s=replace(s,"]","<]>")
s=replace(s,"<","[")
s=replace(s,">","]")
[/tt]
"<" or ">" should be chosen according to cases. Basic is to avoid collision of character inside s. Choose some exotic characters (or combination of characters) at their places if deemed necessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top