Named captures refers the the way a programmer can access the remembered and labeled parts of a string after a regex match.
Questions tagged [named-captures]
27 questions
1
vote
2 answers
allMatches not matching several groups exactly
I thought I knew about regex... Here's the situation:
N-U0 U0-M1
M1-T9 T9-R10 R10-E19
E19-L100 L100-B
I have a String that contains groups (let's call them transitions) separated by whitespace (may or may not be line breaks, I'm treating both…

GuiRitter
- 697
- 1
- 11
- 20
1
vote
3 answers
Regular expression for extracting a noun in variable order
I have the following text:
Action by Toni Kroos, Real Madrid. Rayo Vallecano 2, Real Madrid 0.
where the nouns are Toni Kroos, Real Madrid (team1) and Rayo Vallecano (team2).
I need a regular expression with a named capturing group that returns…

David Miguel Yusta
- 41
- 4
1
vote
1 answer
Regex won't compile because of 'unclosed character class' in named capture group
I am getting "Error: unclosed character class" in a Rust regex. Testing the regex using an online Regex tester with PCRE compliant regexes works fine, but using the regex crate on the Rust Playground gives an error.
The character class must include…

Paul Chernoch
- 5,275
- 3
- 52
- 73
1
vote
1 answer
RegEx for capturing group not recognized
I have the following Regex:
(?:\/(?family-resources|employer-resources|newsroom|text-pages))?\/(?:(?[0-9A-z=\-\s]+\/?)+)
As you can see, I'm trying to set up two named capture groups - root and path. However, when running this and…

Paul
- 1,375
- 2
- 21
- 55
1
vote
1 answer
preg_replace_callback: including curly braces in a pattern: { is captured, } isn't
I have this function, which makes use of preg_replace_callback to split a sentence into "chains" of blocks belonging to different categories (alphabetic, han characters, everything else).
The function is trying to also include the characters ' , {…

resle
- 2,254
- 4
- 19
- 37
1
vote
2 answers
Why can't I capture more than one digit in substring?
I am creating regex to extract various fields from logs files. I have created one regex using some tools and its almost complete. the only thing is for one field its extracting only one digit instead of full number. for better understanding I have…

Ankit Goyal
- 151
- 1
- 12
1
vote
1 answer
how to use a named regex capture before OR after a non capturing group when named capture groups cannot be used twice?
I'm using regex in a python script to capture a named group. The group occurs before OR after a delimiter string "S". My confusion comes from an inability to use named capturing groups twice in the same regex.
I'd like to use the following invalid…

twinturbotom
- 1,504
- 1
- 21
- 34
0
votes
0 answers
JavaScript RegEx: How do I utilise named capture groups?
I am currently working at a Plugin for RPG Maker MZ and for that, i learned how to use RegEx for analyzing the Content of a Notetag. While my first try with them was actually pretty good, i assume it didn't used the full potential of RegEx and…

Helli
- 3
- 3
0
votes
1 answer
Python RE lib - returns match and NONE
My Issue
I am trying to just return the valid IP (the task only wants 1-255.0-255.0-255.0-255 i.e. no leading 0's)
My Regex is matching just fine, and I have a much less sturdy solution to get the question "right" but I am trying to understand why…

aRustyDev
- 101
- 1
- 11
0
votes
1 answer
How can I utilize PCRE and named capture groups from Bash such that I can export variables back to the parent environment?
Is it possible to invoke a program such as Perl from a Bash script to perform a regex with named capture groups and export the results as variables back to the parent shell?
For example:
#!/bin/bash
input="a small box"
regex="a (?P\w+)…

Zhro
- 2,546
- 2
- 29
- 39
0
votes
1 answer
named capturing group inside negative lookbehind regex
I want to avoid catching input as:
:):) but want to catch sa:)ds
or simply want to exclude from result if there are two or more of the same tags which are touching one another.
My logic says I need to use negative lookbehind and named capture group …

Georgi
- 107
- 1
- 6
-1
votes
1 answer
Return a single regex match's Named Capture Group name and value
I have this Tokinizer Class that breaks up a string input:
public class Tokinizer
{
public static Regex r = new Regex(
"(?=)" +
"|(?\\+)" +
"|(?\\-)" +
…

TyperMan1133
- 65
- 7