Thursday, April 22, 2010

Java:Wrap a HTML word with some HTML tags

Input : A Given HTML String
Output : A formatted HTML string with a word wrapped up with some HTML tags.

String startTag = "";
String endTag = "
";
String title = "Hi My Name is AMulya Mishra";
String keyWord = "AMulya";

title = title.replaceAll("(?i)\\b\\p{Alpha}*" + keyWord + "\\p{Alpha}*\\b",startTag + "$0" + endTag);


output = "Hi My Name is AMulya Mishra"

1 comment:

Jackie Co Kad said...

Very much useful article. Kindly keep blogging

Java Training in Chennai

Java Online Training India