I'm trying to create regex to parse markdown links.
regex:
!\[[^\]]*\]\((.*)\s"(.*[^"])"?\s*\)
Test (link to live demo):
foo

bar
Group 1 will be image 2.png
, and group 2 will be hello world
.
The problem appears when I try to parse a link without title:
foo

bar
How I should modify regex to make it work in both cases?
"
in the pattern in not optional so it would never match without quoted title. Also, group1 and group2 do not match what you say they do currently.