470,581 Members | 2,427 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,581 developers. It's quick & easy.

vbscript regex

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!
Jul 19 '05 #1
4 3757
What would z become, }? Would Z become ]? Do you want case sensitivity?
Numbers?

Ray at work

"Michael L." <mi*****@netvision.net.il> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
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!

Jul 19 '05 #2
"Michael L." <mi*****@netvision.net.il> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
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
Jul 19 '05 #3
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" <no****@thankyou.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...
"Michael L." <mi*****@netvision.net.il> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #4
"Michael L." <mi*****@netvision.net.il> wrote in message
news:O$*************@TK2MSFTNGP11.phx.gbl...
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" <no****@thankyou.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...
"Michael L." <mi*****@netvision.net.il> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
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


Function crf(m,p,s)
Select Case m
Case "a" crf = "%20%40"
Case "b" crf = "%D0%B5"
End Select
End Function

HTH
-Chris Hohmann

P.S. Please do not top post/bottom quote. It makes it difficult for
others who are trying to follow this thread.
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by MichaelPyles | last post: by
9 posts views Thread by Tim Conner | last post: by
20 posts views Thread by jeevankodali | last post: by
6 posts views Thread by Extremest | last post: by
7 posts views Thread by Extremest | last post: by
3 posts views Thread by aspineux | last post: by
15 posts views Thread by morleyc | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.