matching any character including newline, in a RegExp

B

Bart Lateur

In Perl, matching any character, including newline, can be done with the
/s regexp switch, as /.+/s matches a string of any character.
Apparently, the Javascript RegExp engine doesn't recognize that switch.

So, what must I use? I'm now using

(?:.|\n)+

but looks inefficient to me: A character class is allegedly vastly
faster than an alternation.

I've thought of

.*(?:\n.*)*

but I have doubts about this one, too.
 
B

Bart Van der Donck

Bart said:
In Perl, matching any character, including newline, can be done with the
/s regexp switch, as /.+/s matches a string of any character.
Apparently, the Javascript RegExp engine doesn't recognize that switch.
So, what must I use? [...]

/[\s\S]/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top