简体   繁体   English

为什么 html 内容不匹配相当简单的正则表达式?

[英]Why wouldn't html content match a fairly simple regex?

I'm having html page content as a string and trying to check if it matches regexp of ^.+$ .我将 html 页面内容作为字符串并尝试检查它是否与^.+$的正则表达式匹配。 And it returns false.它返回错误。 Can't get why it does so.不明白为什么会这样。

Code is fairly simple:代码相当简单:

content.matches(regexp)

By default, the .默认情况下, . does not match \r and \n .不匹配\r\n To let .. also match them, enable DOT-ALL (the s flag):也匹配它们,启用 DOT-ALL( s标志):

^(?s).+$

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

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