Randomblue
Randomblue

Reputation: 116443

regular expression converter (from PHP to JavaScript)

This is the PHP regular expression I would like to convert into a JavaScript regular expression:

/(?<!\..|\...|\....)([\?\!\.]+)\s(?!.\.|..\.|...\.)/u

Are there tools to do such a conversion?

Upvotes: 1

Views: 2079

Answers (1)

Jani Hartikainen
Jani Hartikainen

Reputation: 43273

(?<!stuff goes here) is a negative lookbehind which isn't supported by JavaScript's regex implementation. There are some ways to mimic it, but it does not work properly for all cases - yours looks like one of those to me.

If you want to keep using this specific regex, but from JavaScript, you could consider simply passing the string to PHP using Ajax, which would then run the regex on it.

Upvotes: 2

Related Questions