I want split bellow string with numbers means coordinates. Please help me split pattern in java
34°6′19″N 74°48′58″E / 34.10528°N 74.81611°E / 34.10528; 74.81611This is very good place for tour
This string I want separate string
1. 34°6′19″N 74°48′58″E / 34.10528°N 74.81611°E / 34.10528; 74.81611
2. This is very good place for tour
I have used possible patterns, but not get proper results
1. (?=\\d)(?<!\\d)
2. (?<=[0-9])(?=[a-zA-Z])
3. [^A-Z0-9]+|(?<=[A-Z])(?=[0-9])|(?<=[0-9])(?=[A-Z])
Try :
public static void main(String[] args) {
String s = "34°6′19″N 74°48′58″E / 34.10528°N 74.81611°E / 34.10528; 74.81611This is very good place for tour";
String[] arr = s.split("(?<=\\d)(?=[A-Z])");
System.out.println(arr[0]);
System.out.println(arr[1]);
}
O/P :
34°6′19″N 74°48′58″E / 34.10528°N 74.81611°E / 34.10528; 74.81611
This is very good place for tour
s.split("(?<=\\\\d)(?=[AZ])")
--> Split based on any capital character preceeded by a digit - don't capture / lose any char
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.