DEV Community

loading...

Discussion on: How YOU can learn enough RegEx in JavaScript to be dangerous

Collapse
tracycss profile image
Jane Tracy 👩🏽‍💻

In regex there is /./ that matches all characters apart from line terminators.
Examples of line terminators are...?

Thread Thread
softchris profile image
Chris Noring Author • Edited

line terminators are \n and \r.. If you have code like this that matches a string 'aa \n bb'.match(/.*/), It only matches aa, as match function only runs on the first line (\n separates line one and two). However if you use the flag g it matches all rows. So this code 'aa \n bb'.match(/.*/g) would match aa and bb

Thread Thread
tracycss profile image
Jane Tracy 👩🏽‍💻

Thank you. Very helpful

Forem Open with the Forem app