View Single Post
  #10 (permalink)  
Old 05-08-08, 04:55 AM
hem1234 hem1234 is offline
New Member
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cool

Quote:
Originally Posted by mohit View Post
Thanks,

but i have done it in something different way.
i used this

([a-zA-Z]+/[A-Z]+) (of/[A-Z]+) ([a-zA-Z]+/[A-Z]+)

then use replace it with $1 $3

Code:
String regex ="([a-zA-Z]+/[A-Z]+) (of/[A-Z]+) ([a-zA-Z]+/[A-Z]+)";
Pattern pattern=Pattern.compile(regex);
Matcher matcher= pattern.matcher(string);
while(matcher.find()){
		String str="";
                str= string.substring(matcher.start(),matcher.end());
                 str = pattern.matcher(str).replaceAll("$1 $3");
}
it worked for me.

thanks for contribution
Thanks for the code
Reply With Quote