Skip to content Skip to sidebar Skip to footer

Implicit And Explicit Regex Creation Yield Different Exec Results

I am searching on a largeish (500kb) document with a regex. I am using node.js (v0.10.13), but the behaviour is the same in Chrome (31) DevTools. With implicit regex creation I g

Solution 1:

When you create RegEx's with RegExp, you need to escape the special characters with double backslashes, like this

new RegExp('worker(?:.|\\n)+Name:\\s+(.+?)\\s+Job title').exec(text)

Post a Comment for "Implicit And Explicit Regex Creation Yield Different Exec Results"