I have set of string in below formats
Local Tax 02/07 02/14 -0.42
I want to split the above as three separate stings like
Local Tax
02/07 02/14
-0.42
I wrote the following code snippet
package com.demo;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DemoClass {
/**
* @param args
*/
public static void main(String[] args) {
String s ="Sales Tax 08/07 09/06 0.42";
//String s1 = "Sales Tax 02/07 02/14 -1.02";
Pattern pattern = Pattern.compile("^([a-zA-Z ]*) ([0-9]{2}/[0-9]{2} [0-9]{2}/[0-9]{2}) ([-[0-9]*.[0-9][0-9]|[0-9]*.[0-9][0-9]])");
Matcher matcher = pattern.matcher(s);
if (matcher.find()) {
System.out.println("String Name::"+s);
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
System.out.println(matcher.group(3));
}
}
}
and I am getting output as
String Name::Sales Tax 08/07 09/06 0.42
Sales Tax
08/07 09/06
0
the matcher.group(3) should return 0.42 but it is displaying as 0. could some help me on this please.