how to replace parts of string using regular expressions
<p>I am not a beginner to regular expressions, but their use in perl seems a bit different than in Java. </p>

<p>Anyways, I basically have a dictionary of shorthand words and their definitions. I want to iterate over words in the dictionary and replace them with their meanings. what is the best way to do this in JAVA?</p>

<p>I have seen String.replaceAll(), String.replace(), as well as the Pattern/Matcher classes. I wish to do a case insensitive replacement along the lines of:</p>

<p><code>word =~ s/\s?\Q$short_word\E\s?/ \Q$short_def\E /sig</code></p>

<p>While I am at it, do you think that it is best to extract all the words from the string and then apply my dictionary or just apply the dictionary to the string? I know that I need to be careful, because the shorthand words could match parts of other shorthand meanings.</p>

<p>Hopefully this all makes sense.</p>

<p>Thanks.</p>

<p>Clarification:</p>

<p>Dictionary is something like:
lol:laugh out loud, rofl:rolling on the floor laughing, ll:like lemons</p>

<p>string is:
lol, i am rofl</p>

<p>replaced text:
laugh out loud, i am rolling on the floor laughing</p>

<p>notice how the ll wasnt added anywhere</p>
