Domanda

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?

È stato utile?

Soluzione

You can use:

/^ *#(.*)$/m

And capture match[1] for text after #

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top