Scott Shipp
2014-01-23 18:12:14 UTC
I need some advice on how to do something better. Right now I do a search for a word in a string but only if it is its own word. For example the name suffix, "Jr." One regular expression for it is "\\bJr.\\b" but I find that this does not match when "Jr." is either at the beginning or the end of a line. So I end up making the regular expression "\\bJr.\\b|^Jr.\\b|\\bJr.$" to catch all cases. Basically, this is saying Jr. as a word between two other words OR Jr. at the start of a line before another word or Jr. at the end of a line after another word.
This seems clumsy to me. Is there a more elegant way to catch these cases?
Scott
This seems clumsy to me. Is there a more elegant way to catch these cases?
Scott