-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: named capture groups and reference #66
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mdjastrzebski
changed the title
Feat/named reference
feat: named captured groups and reference
Mar 1, 2024
mdjastrzebski
force-pushed
the
feat/named-reference
branch
from
March 4, 2024 09:01
538e2c9
to
08192db
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 183 190 +7
Branches 41 42 +1
=========================================
+ Hits 183 190 +7 ☔ View full report in Codecov by Sentry. |
mdjastrzebski
force-pushed
the
feat/named-reference
branch
from
March 12, 2024 21:02
08192db
to
ff359a2
Compare
CC: @PaulPhilp |
mdjastrzebski
force-pushed
the
feat/named-reference
branch
2 times, most recently
from
March 28, 2024 12:07
9bb2ea1
to
0ac8420
Compare
mdjastrzebski
changed the title
feat: named captured groups and reference
feat: named capture groups and reference
Mar 28, 2024
wip chore: more tests feat: improved refs refactor: merge name and ref refactor: self code review refactor: tweaks refactor: rename reference to ref feat: example with html tags chore: self code review
mdjastrzebski
force-pushed
the
feat/named-reference
branch
from
April 3, 2024 14:35
0ac8420
to
f2ad95c
Compare
Merging this PR in a more restrictive syntax, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
capture(...)
generates a Capturing Group ((...)
in regex syntax). When callingString.match()
orRegex.exec()
, the result will beArray
-like object. At index0
it will hold whole matched regex, at indexes1
and later it will hold values captured by consecutive capturing groups in the regex.capture(..., { name: 'aaa' })
generates a Named Capturing Group ((?<aaa>...)
in regex). It results are also available on thematch()
result at specified indexes like regular Capturing Group. In addition to that, match result will also expose matched results by name, underresult.group.aaa
, etc. for each Named Capturing Group in the regex.Captured value can also be used during matching using Backreferences. Backreference can either refer to Capuring Group order (
\1
,\2
, etc) or name (\k<aaa>
, etc). In TS Regex Builder to use backreference we need to do following:Alternatives
Base idea:
Alternative 1: separete
name
andref
options:Alternative 2: explicitly define
namedCapture
:Test plan