on 10-23-2008 12:23 PM
Hi everybody,
I have problems to find a fitting RegEx for the following:
strInput = "elvis";
regex = "^e^l^v^i^s";
if (strInput.matches(regex)) {
System.out.println("Hit: " + strInput);
} else {
System.out.println("No hit for: " + strInput + " regex" + regex);
}
I want to check if a String is unequal to "elvis"
The above coding does not work?
e.G. if you use "x_elvis" instead of "elvis", it should match
Thanks
Regards
Hello Mario,
try this:
regex = "^$|^[^e].*|^e$|^e[^l].*|^el$|^el[^v].*|^elv$|^elv[^i].*|^elvi$|^elvi[^s].*|^elvis.+";
The character ^ means "beginning-of-line" when not in brackets; in brackets it means negation.
Best regards,
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.