Not too familiar with regex so could use some pointers in the right direction if possible.
I have some possible String values which can be something like the following:
"88976756 ABC 33ddf33a24"
"89999ABC 3hhhj33"
"7ffhh7AB C78788sd"
What I need is to find if a value ABC exists in those Strings but is not preceded or followed by an alphanumeric character.
In the above examples, only the first should return ABC. The second example is preceded by a digit and the third has a space in the middle.
If anybody knows of a way to do this or has some documentation around the best way to do it I'd appreciate it.
Edit: The Strings above were probably a bit simplistic. Some further examples below
"67676/'ABC'7866cc"
ABC should be found as there is no alphanumeric character before or after it
"88xx#'\A2C"
A2C should be found as there is no alphanumeric char before or after
"88xx# A2C&&&88"
A2C should be found as there is no alphanumeric char before or after
"88xxA2C&&&88"
A2C should not be found as there is an alphanumeric char before it
Thanks
Use the word boundary matcher \b
Your regex could be as simple as
\bABC\b