正则表达式匹配所有字符包括回车 return

Regular expression matching all characters including carriage return

匹配所有字符(.*)且带回车return的正则表达式是什么?

Regular expression that matches all characters (.*) with also carriage return?

(?s).*

demo

(?s) 标志使 . 匹配任何字符,甚至是换行符。

标志也可以设置在第二个分隔符之后:

$re = "/.*/s"; 

another demo