Wednesday 22 June 2016

Javascript regex includes new line into matches




I have a regex to match strings beginning with 'acl' and containing some words.



/[^.](acl\s+.*\s+localport\s+.*)/g



https://jsfiddle.net/bra1c8x4/1/



For some reason output matches new line character even though it's not included in the parentheses!



Does anyone know what's going on here?


Answer



[^.] matches a newline, since a newline is not a dot.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...