[英]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)(?=[AZ])")
->根据任何以数字开头的大写字母进行分割-不要捕获/丢失任何字符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.