Question

I need to capture all lines starting with the # character in JavaScript. I tried using something like the following regex, but it turns out that JavaScript doesn't support positive lookbehind assertion (?<=).

/(?<=\n)\#[^\n]*/g

How can I transform this regular expression into something supported by JavaScript?

Was it helpful?

Solution

You can use:

/^ *#(.*)$/m

And capture match[1] for text after #

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top