user2726225
user2726225

Reputation: 99

Converting a php regex to javascript

how to convert the following php regex to javascript regex?

php regex:- (?s)(?<=<a).*?(?=<\/a>)

Upvotes: 0

Views: 228

Answers (1)

Aran-Fey
Aran-Fey

Reputation: 43166

It's not possible to use the exact same pattern in javascript, because lookbehinds aren't supported.

The best I could do is

<a([^]*?)(?=<\/a>)

It should match the same text as the php regex, but captures the text in the first capture group instead.

Upvotes: 2

Related Questions