I have a little AS3 script to convert all special characters in a string to their character codes.
Here is the script:
url = url.replace(new RegExp("%","g"),"%25")
.replace(new RegExp("?","g"),"%3F")
.replace(new RegExp(":","g"),"%3A")
.replace(new RegExp("/","g"),"%2F")
.replace(new RegExp("=","g"),"%3D")
.replace(new RegExp("&","g"),"%26");
Now, I’m not even a beginner with RegExp, but I gave it a try.
The little script seems to do the trick quite well, but only the question mark (?) isn’t replaced.
Anyone who can tell me why?
If you can also tell me a more short way to code this, feel free to share it, I know this isn’t the best practice of RegExp…
greets
You have to escape the question mark:
"\?"