Posted By

adrianparr on 03/16/10


escape regex replace regexp regular Expression urlencode as3 slash forward forwardslash 2F

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


AS3 Convert a Forward Slash to URLEncoded Character %2F

 / Published in: ActionScript 3

In AS2 forward slashes got url-encoded to %2F when you escaped them. But in AS3 they get ignored and left as they are. In some situations I have found that this can cause problems. So you can do it manually using this regular expression.

  1. var myString:String = "/";
  2. trace(myString);
  3. var urlEncodeForwardSlashedRegExp:RegExp = new RegExp("/", "gi");
  4. myString = myString.replace(urlEncodeForwardSlashedRegExp, "%2F");
  5. trace(myString);
  7. // OUTPUT
  8. // /
  9. // %2F

Report this snippet  

You need to login to post a comment.