Chris hi,
Actually I need "a" to become: "%20%40", "b" to become: "%D0%B5", etc.
This is a special converting I need, that has to be case senstive. (I will
fill in the rest of the switching).
Really what I'm after is a way to replace 1 set of strings (in a list) to a
2nd set of strings.
So that "backa" would be something like:
%D0%B5%20%40ck%20%40 (assuming I defined replacements only for a and b)
Can you help?
Thanks!
Chris Hohmann said:
Michael L. said:
Hi there,
I'm looking for a way to replace each occurence of each character in a
string to different characters.
i.e - the pattern is a=d, b=e, c=f
so that the string "back" would be "edfk"
How can I do that?
Thanks!
<script language="VBScript" runat="SERVER">
Function crf(m,p,s)
crf = Chr(Asc(m)+3)
End Function
Dim re
Set re = New RegExp
With re
.Global = True
.Pattern = "[abc]"
Response.Write .Replace("back",GetRef("crf"))
End With
</script>
<script language="JavaScript" runat="SERVER">
Response.Write("back".replace(/[abc]/g,function(m,p,s){return
String.fromCharCode(m.charCodeAt(0)+3);}));
</script>
HTH
-Chris Hohmann