Wednesday, December 26, 2007

String - replaceAll method

String body = "How are you? Fine.. Who are you";

If you want to replace all 'are you?' in the body with 'is it?', then we can use replaceAll method in String class.
But the code won't work if you write like this
body = body.replaceAll("are you?", "is it?");

Because the replaceAll method treats the first parameter as a regular expression pattern. So the ? mark in the "are you?" is treated as a meta character and it finds no matches for the regular expression and replaces nothing.

To treat meta characters as ordinary character, enclose the "are you?" string within \Q and \E i.e "\Qare you?\E".

body = body.replaceAll("\\Qare you?\\E", "is it?");

The above code will replace all the matches of "are you?" successfully.

i18n

i18n stands for Internationalization.
The i denotes the starting letter, n denotes the ending letter and 18 represents the number letters in between i & n in the word Internationalization.

Internationalization is a process to support local requirements.

Monday, November 5, 2007

I have lived 23 years

November 5th was my birthday. I usually don't celebrate my birthday. But this one was a special one. Raja, my friend made me troubled with full of joy. He informed to all friends about my birthday and everyone called me at midnight and wished me. I really enjoyed the moment and a great thanks to Raja.