How to loop all the elements that match the regex?

前端 未结 8 1528
囚心锁ツ
囚心锁ツ 2020-12-02 18:27

Here is the case: I want to find the elements which match the regex...

targetText = \"SomeT1extSomeT2extSomeT3extSomeT4extSomeT5extSomeT6ext\"

8条回答
  •  温柔的废话
    2020-12-02 18:53

    I was actually dealing with this issue. I prefer Lambda functions for about everything.

    reg = /e(.*?)e/gm;   
    var result = reg.exec(targetText);
    
    result.forEach(element => console.log(element));
    

提交回复
热议问题