I'm trying to write code which finds all words that are in the following format
"some text":
So alphanumeric characters which are within " symbols and which end with the : symbol. My goal once I find these is to remove the " character and wrap the entire string in tag. So after the code has run, the above text would look like this,
<strong>some text:</strong>
So I believe the regex to find such text for wrapping is the following (formatted for Java),
(\".*?\"):{1}
And by using the following code, I should be able to iterate through all the matches.
Pattern pattern = Pattern.compile("(\".*?\"):{1}");
Matcher matcher = pattern.matcher(stringToSearch);
while(matcher.find()) {
String matchedGroup = matcher.group();
matchedGroup = matchedGroup.replaceAll("\"", "");
matchedGroup = "<strong>" + matchedGroup + "</strong>";
// now what?
}
So I probably went about that all wrong.
Now that I've wrapped the word I wanted in a strong tag, how do I "put it back" where it was?