如何在 java 中用数字(坐标)拆分字符串?
How to split string with number(coordinates) in java?
我想用数字分割波纹管字符串表示坐标。请帮我拆分 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
这个字符串我要单独的字符串
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
我使用了可能的模式,但没有得到正确的结果
1. (?=\d)(?<!\d)
2. (?<=[0-9])(?=[a-zA-Z])
3. [^A-Z0-9]+|(?<=[A-Z])(?=[0-9])|(?<=[0-9])(?=[A-Z])
尝试:
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)(?=[A-Z])")
--> 根据前面有数字的任何大写字符进行拆分 - 不要捕获/丢失任何字符
我想用数字分割波纹管字符串表示坐标。请帮我拆分 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
这个字符串我要单独的字符串
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
我使用了可能的模式,但没有得到正确的结果
1. (?=\d)(?<!\d)
2. (?<=[0-9])(?=[a-zA-Z])
3. [^A-Z0-9]+|(?<=[A-Z])(?=[0-9])|(?<=[0-9])(?=[A-Z])
尝试:
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)(?=[A-Z])")
--> 根据前面有数字的任何大写字符进行拆分 - 不要捕获/丢失任何字符