Skip to content
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

Escaping regexps question/bug ? #250

Closed
jbruchanov opened this issue Nov 9, 2017 · 1 comment · Fixed by #260
Closed

Escaping regexps question/bug ? #250

jbruchanov opened this issue Nov 9, 2017 · 1 comment · Fixed by #260

Comments

@jbruchanov
Copy link

I'm working on android app using not simple rive scripts.
Not using java lib because of aichaos/rivescript-java#54.
So running this library in https://github.com/square/duktape-android.
However duktape is complaining about invalid escaping of regexps.
It's about escaped underscore \_ and expected is just _
for example here
(

if line.match(/[^A-Za-z0-9\_\-\s]/)
).

i'm wondering why is _ escaped if it's not regexp special char, is it something from coffee script or some javascript compatibility/new stuff ?

@kirsle
Copy link
Member

kirsle commented Nov 27, 2017

i'm wondering why is _ escaped if it's not regexp special char, is it something from coffee script or some javascript compatibility/new stuff ?

Probably just me programming extra defensively (and coming from a Perl background, where all sorts of things can be surprise meta characters but escaping things that don't need escaping isn't harmful). The escaping probably isn't necessary at all. 😄

You may send a PR that removes the escaping of underscores in regexps.

Lily418 added a commit to ctrlgroup/rivescript-js that referenced this issue Apr 19, 2018
Escaping the underscore in JavaScript Regular Expressions is not necessary. This closes aichaos#250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants