I’m trying to extract the last tags from markdown
const doc = `
# Section title 1
body 1
#t1 #t2
`
const re = /^([sS]*?)nn((#[a-z][a-zd]*s*)+)$/gi
console.log(re.exec(doc))
But the result is somewhat unexpected
[
"n# Section title 1nnbody 1nn#t1 #t2n",
"n# Section title 1nnbody 1",
"#t1 #t2n",
"#t2n"
]
I would expect it to be
[
"n# Section title 1nnbody 1nn#t1 #t2n",
"n# Section title 1nnbody 1",
"#t1 #t2n"
]
P.S. I need the g
modifier, I don’t want to threat n
specially, the text should be interpreted as a stream of chars, not lines.