valoricDe / MultiRegExp2

Get all matches of a regexp with corresponding start and end positions
GNU General Public License v3.0
12 stars 5 forks source link

nested groups do not work #10

Open mafar opened 5 years ago

mafar commented 5 years ago

regex101: https://regex101.com/r/Whivxv/1

JSFIDDLE: (with MultiRegExp2 usage for same test case) https://jsfiddle.net/bababalcksheep/o104bcq6/18/

image

should return 2 matches , each macth has 1 full match and 2 gruops

mafar commented 5 years ago
  1. I think yo uare not using flags . If you turn off global flag @ https://regex101.com/r/Whivxv/1 then result is same as MultiRegExp2
  2. How can i pass flags to new MultiRegExp2(string, flags) like vanilla js new RegExp(string,flags);
  3. Do the flags get consumed automatically fora given string ? like var string = "/abc/ig"
mafar commented 5 years ago

I will propsoe function renaming as well since from https://regex101.com and possibility if mutipule matches ,

  1. A regex can have more than one matches
  2. Each match can have a fullMatch (result_array 0) and more than one groups (result_array 0+n)

execForAllGroups(string: string, includeFullMatch: boolean) renamed to execAll(string: string) I dont see why , includeFullMatch: booleanwould be needed in this case this way if global flagwas used then for more than one matches user can loop through matches If there was no global flag, user can just use array (0) which is first Match , or he can still loop through it but it will have one result anyway

mafar commented 5 years ago

execForGroup(string: string, group: Number) can be renamed to execForMatchGroup(string: string, match: Number, group: Number)

mafar commented 5 years ago

it will be very standard experience if user is given all flag choices instead of forcing it.

mafar commented 5 years ago

oh and return result would be [ [match0] [match1] [match..n]] instead of [match0] which is case right now