My regular expression has 2 different outputs from the same code... but i don't know what's wrong. Here's a piece of code, i hope you can help me. Thanks!
String s = "48° 18′ 13,94″ nördliche Breite, "
+ "11° 34′ 31,98″ östliche Länge";
String kommazahl = "[0-9]{1,2}([\\.,][0-9]+)?";
String zahl = "[0-9]{1,2}";
Pattern p1 = Pattern.compile("("+ zahl +"[°/| ]{1,2}"+ zahl +"(['′/| ]{1,2}("+ kommazahl +")?)?).*"
+"("+ zahl +"[°/| ]{1,2}"+ zahl +"(['′/| ]{1,2}("+ kommazahl +")?)?).*");
Matcher m1 = p1.matcher(s);
System.out.println(m1.group(1) + "\n" + m1.group(5));
// Output should be:
// 48° 18′ 13,94
// 11° 34′ 31,98
// Output is:
// 48° 18′ 13,94
// 1° 34′ 31,98