I have a bunch of Strings in this format:
Barry's Restaurant 100 East Main Street
And I want to split the string into two parts:
Barry's Restaurant
100 East Main Street
So, I need to split the string at the first occurrence of an integer (the street address). Any help is appreciated, thanks
If I understand your question, you could do it with something like
public static void main(String[] args) {
String line = "Barry's Restaurant 100 East Main Street";
String[] arr = line.split("\\d+", 2);
String pt1 = arr[0].trim();
String pt2 = line.substring(pt1.length() + 1).trim();
System.out.println(pt1);
System.out.println(pt2);
}
Output is
Barry's Restaurant
100 East Main Street
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With