search

Home  >  Q&A  >  body text

javascript - js regular match the content in parentheses

var aa="ldfjsldfj(dsfasjfj3124123)";
There is any content in the parentheses, how to match it

迷茫迷茫2749 days ago769

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-07-05 10:41:41

    var aa="ldfjsldfj(dsfasjfj3124123)";
    var result = aa.match(/\(([^)]*)\)/);
    // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
    if (result) {
        console.log(result[1]); // "dsfasjfj3124123"
    }

    reply
    0
  • 高洛峰

    高洛峰2017-07-05 10:41:41

    /(.+)/

    Only take out the contents of parentheses

    reply
    0
  • Cancelreply