substring « Match « 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 » Match » substring 

1. Regex to match against something that is not a specific substring    stackoverflow.com

I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring. Example:

// Updated to be correct, thanks @Apocalisp
^foo.*(?<!bar)$
Should match ...

2. A regex to match a substring that isn't followed by a certain other substring    stackoverflow.com

I need a regex that will match blahfooblah but not blahfoobarblah I want it to match only foo and everything around foo, as long as it isn't followed by bar. I tried using ...

3. How to use regex in java to change prefix and suffix of matching substrings    stackoverflow.com

I'm wanting to (in Java) find any substrings in a string which start with say aba and end in say aca, where there is one or more non-whitespace chars between them. For ...

4. java regex how to match some string that is not some substring    stackoverflow.com

For example, my org string is:

CCC=123
CCC=DDDDD
CCC=EE
CCC=123
CCC=FFFF
I want everything that does not equal to "CCC=123" to be changed to "CCC=AAA" So the result is:
CCC=123
CCC=AAA
CCC=AAA
CCC=123
CCC=AAA
How to do it in regex? If I want everything that ...

5. regex pattern to exclude certain substrings from matches    coderanch.com

For the record, the regex that I actually used, "\\b(?!\\w*?BAD)\\w+\\b", works with the input in your first example. This is because "\\w" won't match a comma, so the lookahead can't see past the next delimiter. That won't work with your second example, since the delimiter is a word character, but the principle is the same: make sure the lookahead doesn't look ...

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.