I’m trying to match the following string, without success.
I’ve this so far.
/\[([^\]]+)(\([^\)]+)/
It’s the last part that won’t work (\([^\)]+).
In other words;
var meta = "[ABC DEF](http://google.com)"
-
This part works.
meta.match(/\[([^\]]+)/) => ABC DEF -
This doesn’t work.
meta.match(/\[([^\]]+)(\([^\)]+)/) // => null
This is what I want.
["ABC DEF", "http://google.com"]
Anyone knows why it won’t work?
You missed the ending
]. Also,)doesn’t need to be escaped in a character class. Thirdly, you could add the trailing), and finally you should not put the literal(inside(...)because you don’t want it to be in the matches array.