Reputation: 985
i have a multi-line matching case in javascript that
seems it should be something like /(?<=.+)\n(?!#)/m
but javascript does not support lookbehind, how can i write this regex?
Upvotes: 2
Views: 46
Reputation: 14345
You can't. A typical trick to get lookbehind is to temporarily reverse the string and act on that, but that only works when there is no lookahead as well. See http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript for some other possibilities including one which supports lookbehind and lookahead (but not expressed as a single regex)--see the section "Mimicking lookbehind using a while loop and regexp.lastIndex".
Upvotes: 1