Regex to extract substring, returning 2 results for some reason

后端 未结 5 1384
情话喂你
情话喂你 2020-11-28 08:13

I need to do a lot of regex things in javascript but am having some issues with the syntax and I can\'t seem to find a definitive resource on this.. for some reason when I d

5条回答
  •  被撕碎了的回忆
    2020-11-28 08:35

    match returns an array.

    The default string representation of an array in JavaScript is the elements of the array separated by commas. In this case the desired result is in the second element of the array:

    var tesst = "afskfsd33j"
    var test = tesst.match(/a(.*)j/);
    alert (test[1]);
    

提交回复
热议问题