user989818
user989818

Reputation:

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?

Upvotes: 5

Views: 11342

Answers (5)

FAYA
FAYA

Reputation: 155

I think that is pretty much simpler, just use /.*/ . stands for any character and * allows any repetition of that character.

Upvotes: 2

mehrdad salehi
mehrdad salehi

Reputation: 1

1.use this

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

Upvotes: 0

marcdahan
marcdahan

Reputation: 3082

var filter =  /.*/gim;

That will match everything across multiple lines.

Upvotes: 1

FailedDev
FailedDev

Reputation: 26940

Why do you use a regex?

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

Upvotes: 0

Rob W
Rob W

Reputation: 349232

All whitespace + non-whitespace = all characters: [\S\s]

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

Upvotes: 8

Related Questions