I would like to match the following
but not the following
My current simple regex pattern is :
Pattern PATTERN_MODULE_NAME = Pattern.compile("com\\.my\\.company\\.(.*?)\\..*")
Matcher matcher = PATTERN_MODULE_NAME.matcher(className);
if (matcher.matches()) {
// will return the string inside the parentheses (.*?)
return matcher.group(1);
}
So, basically, how can i match everything else, but not a specific string, which is the string core in my case.
Please share your ideas on how to achieve that in Java ?
Thank you !
You can use the following regex:
^com\\.my\\.company\\.(?!core).+?\\.MyClassName$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With