1

Even if I use the m flag, javascript regex seems to isolate regex matching by lines.

Example:

"if\nend".match(/if(.*?)end/m)
=> null

I want this to match. How do I get around this?

Dan Palumbo
  • 105
  • 1
  • 7

1 Answers1

2

You actually want s (a.k.a. "dotall"), not m, but javascript doesn't support that. A workaround:

"if\nend".match(/if([\s\S]*?)end/)
georg
  • 211,518
  • 52
  • 313
  • 390