Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是正则表达式:/<\?nib.+\?>/im
/<\?nib.+\?>/im
我在这样的文件上测试它:
<html> <head> <title>OPEN LARK</title> </head> <body> <h1>THIS IS A HEADER <?nib asdf ?> </h1> </body> </html>
我没有比赛。我怎样才能解决这个问题?
您正在使用.匹配多行。这不是在 Javascript 中实现的。检查此答案以获取解决方法。
.
关于解决方法:
代替点,使用类及其否定来匹配所有内容。例如,将 替换.为[\s\S]。
[\s\S]
因为点 ( .) 不匹配换行符。
javascript中的方式是将点替换为[\s\S]