Getting separate parts of a regex in javascript match

This question already has an answer here:

  • How do you access the matched groups in a JavaScript regular expression? 14 answers

  • I believe this is what you're trying to do:

    How do you access the matched groups in a JavaScript regular expression?

    Let me know if that helps.


    Use the exec function of the RegExp object. For that, you'll have to change the syntax to the following:

     var pQe = /(^[a-z ... {0,2})/g.exec(inputText)
    

    Element 1 of the returned array will contain the first element of the match, element 2 will contain the second, and so on. If the string doesn't match the regular expression, it returns null.

    链接地址: http://www.djcxy.com/p/76790.html

    上一篇: 与捕获组的Javascript全球匹配

    下一篇: 在javascript匹配中获取正则表达式的不同部分