Suppose we have one sentence (several words without a dot after the last one).
I need to wrap the last word with some html tags (for example, <strong>lastword</strong>
).
How can I achieve this with java regular expressions?
I've already tried this:
"John Doe Jr".replaceAll ("( .+$)", "<strong>$1</strong>");
but it results in
John<strong> Doe Jr</strong>
p.s. It's ok if we have a whitespace after <strong>
, the main problem is that the pattern matches the biggest subsequence while I need the smallest one.