Multiple replace in 1

Results 1 to 2 of 2

Thread: Multiple replace in 1

  1. #1
    Join Date
    Dec 1969

    Default Multiple replace in 1

    Hi I was wondering with either jscript/vbscript regular expressions you could use one replace statement to replace multiple values... Imagine...<BR><BR>dim myKeys = Array("test1","test2","test3")<BR>dim myVals = Array("val1","val2","val3")<BR><BR>Ok what I would like is say a regexp like <BR>myreg ="(test1)&#124(test2)&#124(test3)"<BR>and call <BR>regObj.pattern = myreg<BR>newstring = regObj.replace(myreg,?) <BR>I guess with that regExp i want to beable to replace test1 with val1 and test2 with val2 etc.. without having to call multiple replace calls. I&#039d appreciate any help give me. T.I.A

  2. #2
    Join Date
    Dec 1969

    Default RE: Multiple replace in 1

    Sounds like a great opportunity to write a function!<BR><BR>function myReplace (Keys, Vals, Somestring)<BR>NewString = SomeString<BR>ValArray = split (Vals,",")<BR>KeyArray = split (Keys,",")<BR>for i = 0 to (ubound(KeyArray) - 1)<BR> NewString = replace(NewString, KeyArray(i), ValArray(i))<BR>next &#039i<BR>myReplace = NewString<BR>end function<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts