I've almost got a regex question figured out, just one little thing.
I am trying to get this:
and so use [chalk](#api).red(string[, options])
Into this:
and so use chalk.red(string[, options])
I have this:
var md = 'and so use chalk.red(string[, options])';
console.log(md.replace(/(\[.*?\]\()(.+?)(\))/g, '$1'))
Which matches the [x](y)
perfectly. However, $1
returns [chalk](
. I would like it to return chalk
instead, and I'm stumped on how to do this.
I might(?) have figured it out:
Does this do the trick in all cases?
/(\[(.*?)\]\()(.+?)(\))/g