Sunday, October 14, 2012

get data between two special character using java

Let say you want to get data between character ' and " of the below string

String str= 21*90'89"

You can do it really easy by using regular expression and java


Pattern pattern = Pattern.compile("'(.*?)\"");
Matcher matcher = pattern.matcher(str);
 if (matcher.find())
{
         System.out.println(matcher.group(1));
 }

0 comments:

Post a Comment