I was trying case insensitive pattern matching. For the sake of learning i tried the following and finding it difficult to analyze what is happening.
String x = "Hello";
String pattern = "(?i)";
System.out.println(x.replaceAll(pattern, "</code>"));
Output is
</code>H</code>e</code>l</code>l</code>o</code>
Can someone please explain this behaviour
Using
(?i)bare is equivalent to matchingcase-insensitiveempty StringYou need to have something after
(?i)to apply case-insensitivity matching to..That is why this pattern matches every empty string,
after each character, andalso before the first character, and replaces it with : –</code>