Skip to content
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

- add regex group names #1684

Closed
wants to merge 3 commits into from

Conversation

lukeparkinson
Copy link

Addresses #1650

I've recently been using the regex operation with named capture groups. However the name of the group isn't surfaced in the output, and would be handy when I have a lot of groups.

Saw that this is an existing feature request, so added this in.

  • When using regex operation, if including named capture groups then output the name of the group in the 'List matches with capture groups' output format.
regex-named-groups

Test link with data and operation

Thanks

lukeparkinson and others added 3 commits January 3, 2024 22:35
When using regex operation, if including named capture groups then output the name of the group in the 'List matches with capture groups' output format.
@@ -207,7 +207,7 @@ function regexList(input, regex, displayTotal, matches, captureGroups) {
if (captureGroups) {
for (let i = 1; i < match.length; i++) {
if (matches) {
output += " Group " + i + ": ";
output += " Group " + i + " (" + regex.xregexp.captureNames[i - 1] + "): ";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a check to ensure that the current group is named. Otherwise, in the case of no names there is the following error:

Invalid regex. Details: regex.xregexp.captureNames is null

And if there are some that are named and some that are not, the unnamed ones gain a label of 'null', which isn't ideal.

@a3957273
Copy link
Member

Hey, I'm going to close this PR because it doesn't support existing unnamed regular expressions. Feel free to recreate the PR if you update this :)

@a3957273 a3957273 closed this Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants