Specila char. to Hex Value

Results 1 to 2 of 2

Thread: Specila char. to Hex Value

  1. #1
    Sathya Weerasooriya Guest

    Default Specila char. to Hex Value

    Hi,<BR><BR>I am seeking help to do the following;<BR><BR>I want to replace some characters in a string with its hex value. For an example characters & , +, %, # with %26, %2b, %25, %23 respectively. In perl I can do this using one single statement, like $thisString = ~s{([&+%#])}{hx($1)}ge;<BR><BR>Could there be a similar way to do this using VBScript or JScript so that I can use it in an ASP page.<BR><BR>Thanks for any input.

  2. #2
    Jason Miller Guest

    Default Doable, but not pretty.

    Okay, here&#039s how it works:<BR><BR>Regular expression 1 does matches (.execute) for non-alphanumeric characters.<BR><BR>for each match in setOfMatches (from regular expression 1)<BR> myString = replace(myString, match.value, "%" & hex(ascW(match.value)))<BR>next<BR><BR>So you&#039re stepping through the results of a basic match and using a customized replace for each match. Nasty, eh? I&#039m not sure that the syntax is perfect, but this is how I got around this issue (if you notice the earlier Hex Values post...)<BR><BR>HiH

Posting Permissions

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