On JavaScript regular expression non capture grouping

  • 2021-08-03 08:11:50
  • OfStack

Non-captive grouping defines that a sub-expression can be modified as a whole but that the sub-expression matching results are not stored.

Non-captive grouping by placing subexpressions in "? : "After the symbol.


str = "img1.jpg,img2.jpg,img3.bmp";

reg = /(?:\w*)(?=\.gif)/;

arr_m = str.match(reg);//arr_m = ["img1","img2"]

What are you expecting or waiting for? What did you choose or just want to float for one life? The vast sea of people really need to look back and smile.


Related articles: