xregexp
xregexp copied to clipboard
Move to options object APIs
- Allow an
optionsobject as the first optional argument forXRegExp.exec/test/replace/match/forEach, and allow anoptionsobject for eachXRegExp.replaceEachreplacement array.- This will replace or overload/supersede the following optional arguments:
posandstickyofXRegExp.exec/test,scopeofXRegExp.replace/match, and the third value (scope) of eachXRegExp.replaceEachreplacement array. - Since
XRegExp.replace's currentscopeargument is infrequently used (it's more common to set scope via flaggon the provided regex), it might make sense to not overload thescopeargument but instead just replace it. Same forXRegExp.replaceEacharrays.
- This will replace or overload/supersede the following optional arguments:
New features planned after and enabled by moving to options object APIs:
- To enable common lookbehind tasks (where lookbehind is used at the start of the pattern), add
followsanddoesNotFollow(orprecededByandnotPrecededBy) to theoptionsobjects ofXRegExp.exec/test/match/forEach. These would expect regex objects.followswould be used like positive lookbehind, anddoesNotFollowlike negative lookbehind. - Add support for
posandstickytoXRegExp.match/forEach, via theiroptionsobjects.- Cleanup: After adding
posandstickytoXRegExp.match, search forXRegExp.exec(…, …, pos, 'sticky')[0]and replace withXRegExp.match(…, …, {pos: pos, sticky: true, scope: 'one'}).
- Cleanup: After adding
- Add support for
pos,sticky, andscopetoXRegExp.matchRecursive, via its existingoptionsobject.- Note that
matchRecursivealready supports the handling ofscopevia flagg, andstickyvia flagy. These flags should be superseded byposandsticky, the same way thatscopesupersedes flaggwithXRegExp.replace.
- Note that