简体   繁体   English

正则表达式匹配一切

[英]regex to match everything

I'm using the following regular expression to match everything: 我正在使用以下正则表达式来匹配所有内容:

/^(?=.{10,8000}$).*$/

But now I just realize that .* doesn't match the newline character. 但现在我才意识到.*与换行符不匹配。 How can I make this regular expression match newlines? 如何使这个正则表达式匹配换行符?

所有空格+非空格=所有字符: [\\S\\s]

/^(?=[\S\s]{10,8000})[\S\s]*$/

Why do you use a regex? 为什么使用正则表达式?

var txt = "Hello World!";
if(length(txt) >= 10 && length(txt) <= 8000) {//match}
var filter =  /.*/gim;

这将匹配多行的所有内容。

用这个

 var filter = /[\w|\W]*/gim;

I think that is pretty much simpler, just use /.*/ . 我认为这简单得多,只需使用/.*/ stands for any character and * allows any repetition of that character. 代表任何角色,*允许任何重复的角色。

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

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