raplacing chars in strings

Results 1 to 2 of 2

Thread: raplacing chars in strings

  1. #1
    Join Date
    Dec 1969

    Default raplacing chars in strings

    I am having some problems with regular expressions. <BR>Anyone knows how can I replace "[^a-fA-F0-9]" chars with hex(asc($1)) $1 <BR>should be the char that meets the "[^a-fA-F0-9]" expression <BR><BR>Dim RegExp as RegEx <BR>string = "%2CeYCb%0D%7E%21%E6%7F%17/%94%DF%F3%D4j%D8i%12" <BR><BR>string2 = string.Replace("%","") <BR><BR>string = RegExp.Replace(string2, "[^a-fA-F0-9]", hex(asc($1))) <BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: raplacing chars in strings

    Use a loop to accomplish this task, something like this:<BR><BR>Set RegExp = new RegExp()<BR>RegExp.Global = True<BR>RegExp.IgnoreCase = True<BR>RegExp.Pattern = "([^a-f0-9])"<BR>Set colMatches = RegExp.Execute(strTest)<BR>For Each objMatch In colMatches<BR>nextMatch = match.SubMatches(0)<BR>strTest = Replace(nextMatch,Hex(Asc(nextMatch)),1,1,1)<BR>Ne xt

Posting Permissions

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