Is there an equivalent in jQuery to PHP's `preg_replace()`?

后端 未结 3 1703
无人及你
无人及你 2021-01-17 11:13

Say I have the following:


This path could be anything, we basically want to get the

3条回答
  •  清歌不尽
    2021-01-17 11:24

    Working example here: http://jsfiddle.net/jkeyes/sxx3T/

    var re = new RegExp(".*\/(.*)$");
    var src="folder/foo/bar/x982j/second822.jpg";
    var m = re.exec(src);
    alert(m[1]); // first group 
    

提交回复
热议问题