【JavaScript】使用js正则表达式匹配

markdown图片格式如:
![说明](http://www.xxx.com/images/1234567.jpg "标题")

js正则匹配:

var result = str.match(/![(.*)]((S*) "(.*)")/);
var url = result[2];    //http://www.xxx.com/images/1234567.jpg

result[0]:![说明](http://www.xxx.com/images/1234567.jpg "标题")
result[1]:说明
result[2]:http://www.xxx.com/images/1234567.jpg
result[3]:标题

匹配集合数由()数决定,result[0]固定全匹配结果

*:匹配0或任意个前面的字符

.:匹配任意字符

S:匹配任意非Unicode空白符字符

s:匹配任意Unicode空白符

原文地址:https://www.cnblogs.com/Locked-J/p/7105839.html