Wednesday, June 22, 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