I am searching for a String in a file that has any non numeric character and no dollar sign in it. when i use
[\\D&&[^$]]+
it works but if i use
[.&&[^$]]+
the code doesn't work.Can anyone explain the reason.
The .
dot in a char class []
means exactly a dot, not any character as it works outside character classes.
What you're looking for is a negated character class:
RegEx: [^0-9$]
live demo
Inside the character-class []
the .
char is not a wildcard, but an actual dot. You don't need to intersect the dot with your "not" char, you can simply write [^$0-9 ]+
(which is however not what you are looking for I guess).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.