Questions tagged [capturing-group]

Capturing groups are regular expression constructs that makes use of capturing in regex to capture parts of the matched string during a match sequence in the regexp pattern.

Capturing groups and s are regular expression constructs that makes use of capturing in to perform matching and replacement that remembers parts of the matched string during a match sequence in the regexp pattern.

Read more:

223 questions
0
votes
2 answers

A regular expression to match zero or one occurrence of a word in Java

I have written a regex to match following pattern: Any characters followed by hyphen followed by number followed by space followed by an optional case insensitive keyword followed by space followed by any char. E.g., TXT-234 #comment…
h-kach
  • 351
  • 2
  • 8
  • 25
0
votes
1 answer

java, unable to understand the concept of back-referencing within the context of nested capturing group

I'm new to Java and is trying to learn the concept of capturing group. I read on Java tutorial oracle: For nested capturing groups, backreferencing works in exactly the same way: Specify a backslash followed by the number of the group to be …
user5849987
0
votes
2 answers

How to match several capturing groups, but results not as expected

I'm trying to learn the Java Regular Expression. I want to match several capturing group (i.e. j(a(va))) against another string (i.e. this is java. this is ava, this is va). I was expecting the output to be: I found the text "java" starting at…
Thor
  • 9,638
  • 15
  • 62
  • 137
0
votes
1 answer

Assign captured group to value, and if no match: assign string

In Perl regex, the documentation says ... in scalar context, $time =~ /(\d\d):(\d\d):(\d\d)/ returns a true or false value. In list context, however, it returns the list of matched values ($1,$2,$3) But how is it that when you provide an…
Bram Vanroy
  • 27,032
  • 24
  • 137
  • 239
0
votes
0 answers

Capture data from various places and get it insto one named group

I have some data I like to analyze using Splunk. Data is in the follwoing format. 18.02.2016 13:55:55 01D4 PACKET 014D4198 UDP Snd 10.10.10.148 9e8b R Q [8081 DR NOERROR] A (5)rover(4)ebay(3)com(0) 18.02.2016 13:55:27 01C4 PACKET …
Jotne
  • 40,548
  • 12
  • 51
  • 55
0
votes
1 answer

Replacing a single term in a regex pattern

I am using regexp_filter in Sphinx to replace terms In most cases I can do so e.g. misspellings are easy: regexp_filter = Backround => Background Even swapping using capturing group notation: regexp_filter = (Left)(Right) => \2\1 However I am…
user3649739
  • 1,829
  • 2
  • 18
  • 28
0
votes
2 answers

How can I find and print only specific information

I'm trying to have awk print only a specific information. I can make it when it comes only to simple text strings. But its not working when I ask to search and print something like: /[0-9]*\.[0-9]*\.[0-9]*\.[0-99]*\.[0-999]*/ I'm looking for…
ebvogt
  • 43
  • 10
0
votes
3 answers

What am I doing wrong with my regex?

I am trying to capture "Rio Grande Do Leste" from: ...

Rio Grande Do Leste
... using var myregexp = /

()
FernandoSBS
  • 655
  • 5
  • 12
  • 23

0
votes
1 answer

Extract fields of Apache Web Log using PCRE Regex

Using a PRCE Regex, I want to capture each field of different apache weblogs. The structure of these logs is like this example: aaa bbb "cc c" ddd "eee" fff Each field is seperated by a space. But fields may also contain spaces in which case they…
0
votes
0 answers

Using TKinter text tags with regex capturing groups

I'm writing a text editor in Python TKinter, and am currently working on syntax. I am trying to make it underline text in the format: \_ **UNDER line This text 0!** \_ (underline the bolded text) I'm using using regex commands such as :…
Nezo
  • 567
  • 4
  • 18
0
votes
1 answer

Regex: how to extract unique groups matching a pattern

Is there a way to extract unique captured groups matching a regex pattern in c# .net ? I need to a have list uniqueSiteElementKeys3 with 2 elements, SiteElements[10] and SiteElements[11] string lineOfKeys =…
Ntn
  • 3
  • 3
0
votes
1 answer

Java Regex Capturing Groups for {X}

I have a regex with a character sequence. I want the sequences parts into groups. Pattern e_1394Pattern = Pattern .compile("\\dR\\|\\d\\|(((([^\\|]))*\\|){11})"); String resultLine =…
S.F
  • 1
0
votes
5 answers

Java Regex: replace with capturing group

I have a string like this: 123456-1/1234/189928/2323 (102457921) I want to get 102457921. How can I achieve it with regex? I have tried: "123456-1/1234/189928/2323 (102457921)".replaceAll("(\\.*\()(\d+)(\))","$2"); But it does not work. Any hints?
user3111525
  • 5,013
  • 9
  • 39
  • 64
0
votes
1 answer

REGEX: Getting information from a specific group which is surrounded by many optional groups

Suppose I have a regex expression that matches a string like this: (A)(B)?(C)(D)?(E)(F)? where the groups B, D, and F are optional. How can I get just group E? I ask this because, I don't think I can just call M.group(5) because if my matcher (M)…
0
votes
1 answer

how does this regex for email address validation work?

While searching for regular expressions used for email address validation, i came across this page: http://www.regular-expressions.info/email.html. i couldn't understand it. it says: \b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+.)+[A-Z]{2,4}\b will match…
burhan
  • 121
  • 1
  • 9
1 2 3
14
15