<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Case-insensitive replaceAll in Java</title>
	<atom:link href="http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/</link>
	<description>The original website of Jelani Harris the original of course</description>
	<lastBuildDate>Tue, 10 Apr 2012 22:25:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: tchrist</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-397</link>
		<dc:creator>tchrist</dc:creator>
		<pubDate>Sun, 06 Nov 2011 16:07:08 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-397</guid>
		<description>Incredible thought it may seem, Java defaults to only understanding ASCII; it ignores its own native charcter set. So you always need to add &quot;(?u)&quot; to make case insensitivity work on normal Java text, which is Unicode not ASCII.  

Also, if you expect things like \w to work on regular Java text, you need to add &quot;(?U)&quot;, which isn&#039;t even supported until Java J.

 In short, you normally want &quot;(?iu)&quot; for case insensitivity, and you want &quot;(?U)&quot; for the UNICODE_CHARCLASSES flag. 

Note that this is still only the simplistic kind of case insensitivity as provided by the Character class, not full casemappings such as provided by the String class. That will be ok for Spanish and Portuguese, but not for German or Greek.</description>
		<content:encoded><![CDATA[<p>Incredible thought it may seem, Java defaults to only understanding ASCII; it ignores its own native charcter set. So you always need to add &#8220;(?u)&#8221; to make case insensitivity work on normal Java text, which is Unicode not ASCII.  </p>
<p>Also, if you expect things like \w to work on regular Java text, you need to add &#8220;(?U)&#8221;, which isn&#8217;t even supported until Java J.</p>
<p> In short, you normally want &#8220;(?iu)&#8221; for case insensitivity, and you want &#8220;(?U)&#8221; for the UNICODE_CHARCLASSES flag. </p>
<p>Note that this is still only the simplistic kind of case insensitivity as provided by the Character class, not full casemappings such as provided by the String class. That will be ok for Spanish and Portuguese, but not for German or Greek.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deb</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-366</link>
		<dc:creator>deb</dc:creator>
		<pubDate>Tue, 26 Jul 2011 09:53:52 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-366</guid>
		<description>Thanks buddy, 
it was a great help to me. Searching for something like that 
for many hours. Finally ur site helps.

Thanks again, keep up the good work.</description>
		<content:encoded><![CDATA[<p>Thanks buddy,<br />
it was a great help to me. Searching for something like that<br />
for many hours. Finally ur site helps.</p>
<p>Thanks again, keep up the good work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: c9025295</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-326</link>
		<dc:creator>c9025295</dc:creator>
		<pubDate>Thu, 19 May 2011 01:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-326</guid>
		<description>thank you!</description>
		<content:encoded><![CDATA[<p>thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dansesacrale</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-94</link>
		<dc:creator>dansesacrale</dc:creator>
		<pubDate>Tue, 30 Nov 2010 16:50:21 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-94</guid>
		<description>Hi, just wanted to let you know that this blog entry came up as the top hit on a Google search &quot;replaceall case insensitive&quot; (without quotes), and I found it helpful and well-written. Thanks.</description>
		<content:encoded><![CDATA[<p>Hi, just wanted to let you know that this blog entry came up as the top hit on a Google search &#8220;replaceall case insensitive&#8221; (without quotes), and I found it helpful and well-written. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jelani Harris</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-90</link>
		<dc:creator>Jelani Harris</dc:creator>
		<pubDate>Mon, 19 Jul 2010 16:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-90</guid>
		<description>Hello Celso,

I had a hard time trying to follow what exactly you&#039;re trying to do here so I&#039;ll make a few quick assumptions. I&#039;m assuming that you don&#039;t want to eat the whitespace after the search term.

The regex you have set up now is looking for the term &quot;celso&quot; and one other character that is not a single quote (&#039;). Because the space character is not a quote the regex matches the term and a single space - then does the replacement. If you were to set the regex to:
&lt;code&gt;String regex = &quot;&quot;; &lt;/code&gt;
Then you&#039;d be matching all variations of celso without the spaces. 

However if you &lt;strong&gt;just &lt;/strong&gt;wanted to match the WORD &quot;celso&quot;, and not part of another word of a mistype (such as &quot;celsOOOOO&quot; which would turn into &quot;OOOO&quot;) you can use the word boundary regex:
&lt;code&gt;String regex = &quot;\\b&quot;; &lt;/code&gt;

I hope I helped.</description>
		<content:encoded><![CDATA[<p>Hello Celso,</p>
<p>I had a hard time trying to follow what exactly you&#8217;re trying to do here so I&#8217;ll make a few quick assumptions. I&#8217;m assuming that you don&#8217;t want to eat the whitespace after the search term.</p>
<p>The regex you have set up now is looking for the term &#8220;celso&#8221; and one other character that is not a single quote (&#8216;). Because the space character is not a quote the regex matches the term and a single space &#8211; then does the replacement. If you were to set the regex to:<br />
<code>String regex = ""; </code><br />
Then you&#8217;d be matching all variations of celso without the spaces. </p>
<p>However if you <strong>just </strong>wanted to match the WORD &#8220;celso&#8221;, and not part of another word of a mistype (such as &#8220;celsOOOOO&#8221; which would turn into &#8220;OOOO&#8221;) you can use the word boundary regex:<br />
<code>String regex = "\\b"; </code></p>
<p>I hope I helped.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: celso</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-89</link>
		<dc:creator>celso</dc:creator>
		<pubDate>Sun, 18 Jul 2010 20:05:50 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-89</guid>
		<description>&lt;pre lang=&quot;Javascript&quot;&gt;String regex = &quot;[^&#039;]&quot;;
String insentiveCase = &quot;(?i)&quot;;

String DOCUMENTO_SAIDA = &quot;celso foi  celso Celso CELSO&quot;;
String anotacao = &quot;&quot;;
 String termo = &quot;celso&quot;;

DOCUMENTO_SAIDA = DOCUMENTO_SAIDA.replaceAll(insentiveCase + termo + regex, anotacao);

System.out.println(DOCUMENTO_SAIDA);
&lt;/pre&gt;
foi  CELSO

But... he eats space char after the replaced &quot;termo&quot;</description>
		<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">String regex <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;[^']&quot;</span><span style="color: #339933;">;</span>
String insentiveCase <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;(?i)&quot;</span><span style="color: #339933;">;</span>
&nbsp;
String DOCUMENTO_SAIDA <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;celso foi  celso Celso CELSO&quot;</span><span style="color: #339933;">;</span>
String anotacao <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
 String termo <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;celso&quot;</span><span style="color: #339933;">;</span>
&nbsp;
DOCUMENTO_SAIDA <span style="color: #339933;">=</span> DOCUMENTO_SAIDA.<span style="color: #660066;">replaceAll</span><span style="color: #009900;">&#40;</span>insentiveCase <span style="color: #339933;">+</span> termo <span style="color: #339933;">+</span> regex<span style="color: #339933;">,</span> anotacao<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
System.<span style="color: #660066;">out</span>.<span style="color: #660066;">println</span><span style="color: #009900;">&#40;</span>DOCUMENTO_SAIDA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>foi  CELSO</p>
<p>But&#8230; he eats space char after the replaced &#8220;termo&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jelani Harris</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-88</link>
		<dc:creator>Jelani Harris</dc:creator>
		<pubDate>Thu, 17 Jun 2010 14:26:43 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-88</guid>
		<description>Hello Shahin,
I added a $ to my example string and the replaceAll still worked.</description>
		<content:encoded><![CDATA[<p>Hello Shahin,<br />
I added a $ to my example string and the replaceAll still worked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shahin</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-86</link>
		<dc:creator>Shahin</dc:creator>
		<pubDate>Wed, 02 Jun 2010 16:30:08 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-86</guid>
		<description>If you have $ sign in your sentence it wouldn&#039;t work.
like 
String sentence = &quot;The sly brown Fox jumped$ over the lazy foX.&quot;;</description>
		<content:encoded><![CDATA[<p>If you have $ sign in your sentence it wouldn&#8217;t work.<br />
like<br />
String sentence = &#8220;The sly brown Fox jumped$ over the lazy foX.&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leandro</title>
		<link>http://jelaniharris.com/2009/case-insensitive-replaceall-in-java/comment-page-1/#comment-77</link>
		<dc:creator>Leandro</dc:creator>
		<pubDate>Thu, 18 Feb 2010 19:43:40 +0000</pubDate>
		<guid isPermaLink="false">http://jelaniharris.com/?p=67#comment-77</guid>
		<description>Hi! It doesn&#039;t work with accents ... :/
Try: Águia
I consider this a bug.

Do you know some workaround?</description>
		<content:encoded><![CDATA[<p>Hi! It doesn&#8217;t work with accents &#8230; :/<br />
Try: Águia<br />
I consider this a bug.</p>
<p>Do you know some workaround?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

