简体   繁体   English

将php正则表达式转换为javascript

[英]Converting a php regex to javascript

如何将以下php正则表达式转换为javascript正则表达式?

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

It's not possible to use the exact same pattern in javascript, because lookbehinds aren't supported. 在javascript中无法使用完全相同的模式,因为不支持lookbehinds。

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. 它应该与php regex匹配相同的文本,但是捕获第一个捕获组中的文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM