match « group « Java Regex Q&A

Home
Java Regex Q&A
1.Development
2.find
3.group
4.Match
5.matcher
6.number
7.Operation
8.parse
9.Pattern
10.replace
11.validation
12.word
Java Regex Q&A » group » match 

1. In a Java regex with Quantifiers how can I obtain the matched groups?    stackoverflow.com

I am processing text using Java Regexes (1.6) which contain quantifiers and I wish to return the number and values of matched groups. A simple example is:

A BC DEF 1 23 ...

2. Unescaped "." still matches when used in a negation group    stackoverflow.com

I made, what I believed to be, an error in a regular expression in Java recently but when I test my code I don't get the error I expect. The expression I ...

3. Anyone knows which group in a regular expression actually does the matching job    stackoverflow.com

Say I have a regular expression like the fowllowing: {"(group 1) | (group 2) (group 3) |....( group n)"} to match an input String object, if it ...

4. Is there a way to capture each group if multiple occurrences are matched?    stackoverflow.com

I don't know how to explain the problem in plain English, so I help myself with regexp example. I have something similar to this (the example is pretty much simplified):

((\\d+) - ...

5. Regex in java, group matching    stackoverflow.com

Hello how does java and regex group work. For ex. I want to match any text 'something', the way I'd match this is .+\s+'(.+)'{1}, how can I replace any text 'something' ...

6. Regex Matching Question    stackoverflow.com

It's been a few years since I've used regex, but if I remember correctly, the following should work:

String test = "axaxa";
Pattern p = Pattern.compile("([a-c])x\1x\1");
Matcher m = p.matcher(test);
m matches nothing on run. ...

7. Regex to match 2 or none?    stackoverflow.com

I have this regex to identify if the line contains two underscores:

\s*_{2}(\w+)
Any space, two underscores and then a word. It turns out, I need to know also for no underscore ...

8. Java 6 regex multiple matches of one group    stackoverflow.com

Here is simple pattern: [key]: [value1] [value2] [value3] [valueN] I want to get:

  1. key
  2. array of values
Here is my regex: ^([^:]+):(:? ([^ ]+))++$ Here is my text: foo: a b c d Matcher gives ...

9. Regex - match group that contains word AND does not contain another word    coderanch.com

No, it was my fault.. I posted wrong. By matching (.*document.*), I was capturing the whole expression. If the input was "calendar simple", the lookahead (.*simple.*) would have nothing left to match. The correct pattern would be (calendar)(?!.*simple.*). This would return true for "calendar" or 'calendar some words", but false for "calendar simple". I tested this with the RegexTestHarness in the ...

10. regex does not match but has group(0)    coderanch.com

The test page says that matches() returns false. Look at the difference between the matches() and find() methods. My guess is that if the test page reported what find() returned, it would have been true. That's what I would expect for the regex and input you have shown. However I'm not sure why the final " is included - did your ...

11. Get all groups from a regular expression match    forums.oracle.com

Please help me understand how to use Java regular expressions: I have an expression similar to this: "([^X]+)(X[^X]*)+"This should match stuff like "asaasaXdfdfdfXXsdsfd". How does one access all the matches for the second group (the second groups has a Kleene operator added so it is not really just one group --- but match.groupCount() is always 2) Here is roughly the code: ...

12. How to get a group when matching regex?    forums.oracle.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.