I'm having a problem with a regex that should simply replace one string with another. Basically, I want to convert any caps variant of LLC and replace it with LLC. Eg. Llc would become LLC. However, in my case, the result is just the replacement string. There's something that should be obvious that I'm missing.
String pattern = "(?i)(.*?)\\b(LLC.?)\\b(.*?)";
String replacement = "LLC";
String unformatted = "Midwest Horticultural Llc";
String formatted = unformatted.replaceAll(pattern, replacement);
My expectation is that formatted string will be:
Midwest Horticultural LLC
But what I end up with is actually:
LLC
If someone could show me the error of my ways, I would appreciate it.
.*?before yourLLC?