且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在正则表达式中跨多行匹配任何字符?

更新时间:2022-11-15 07:59:32

它取决于语言,但是应该有一个可以添加到正则表达式模式的修饰符.在PHP中是:

It depends on the language, but there should be a modifier that you can add to the regex pattern. In PHP it is:

/(.*)<FooBar>/s

最后的 s 使点与所有字符(包括换行符)匹配.

The s at the end causes the dot to match all characters including newlines.