-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regular expressions: don’t use eval
#11
Comments
https://gist.github.com/WebReflection/6225242 by @WebReflection might be of use. So, is there a clever way to go from |
var re = /abc©\xA9/g;
alert(
JSON.stringify(re.source).replace(
/\\\\(x[a-zA-Z0-9]{2}|u[a-zA-Z0-9]{4})/g,
function(m, c){
return String.fromCharCode(parseInt(c.slice(1), 16));
}
)
);
// string abc©© |
@WebReflection: Neat idea, but doesn't quite work. Try |
Mine was a hint... You can improve that with extra checks/changes ;-) I would have pushed a change otherwise |
E.g.
The output should be
'/\\B/'
.We should get rid of
eval
and parse any escape sequences inregex.source
ourselves.The text was updated successfully, but these errors were encountered: