1

I need to convert this PHP flavoured Regex:

(?<=\A|\;#)(.*?)(?=\;#|\z)

Into Javascript flavoured Regex.

I keep on getting unidentified token error while using the existing PHP version in my code.

Appreciate the help.

1
  • Javascript does not support lookbehinds, I think you may be better off explaining what you are trying to match with some example content Commented Aug 11, 2016 at 2:15

1 Answer 1

0

JavaScript doesn't support lookbehinds, nor are \A and \z anchors.

You don't really even need a lookarounds in that regex. You could just use a non-capturing group, and then access the first capture group. Use ^ instead of \A, and $ instead of \z. You also don't need to escape the ;.

(?:^|;#)(.*?)(?:;#|$)

And then use the value in the first capture group.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.