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

some case wrong #6

Open xinshangshangxin opened 6 years ago

xinshangshangxin commented 6 years ago

like next line RegExp, which with repeat symbol ( + or * ), it will be wrong /(ba)+.(a*)/

regexp.execForAllGroups('bababaaaaa', true);
matches:  [ { match: 'ba', start: 0, end: 2 },
  { match: 'aaa', start: 3, end: 6 } ]

I think the regexp should change to /((ba)+).(a*)/ when calculate the next match position

valoricDe commented 6 years ago

Hi @xinshangshangxin thank you for your feedback. I always have to dive in again into the logic. I will have a look at it tonight. If you have any suggestions aka pull request I'll happily have a look at it.

mafar commented 5 years ago

image Pasting code on jsfiddle gives error

valoricDe commented 5 years ago

@mafar 1st. Create a separate ticket 2nd Do you mind posting the url to the jsfiddle. 3rd use npm install multi-regexp2 or the files from dist when not using ES6 compatible environment

valoricDe commented 4 years ago

Hey @xinshangshangxin I never got back to you. (ba)+ is really tricky. it just catches the last occurence of ba. So if I add the capturing group it would have three matching groups altough you only specified two. But on the other hand all developers probably want to know the hole group when they right something like this.