Reputation: 45
So I have the column 'Adress' which has both street and number in there.
So for example:
Londonstreet 13
And I got 2 textfields, for street and number which have to get filled up with:
Street: Londonstreet
Number: 13
If I do
Street.setText(rs.getString("adress");
It puts 'Londonstreet 13' in the Street textfield, while I want just the streetname.
How to fix this?
Upvotes: 1
Views: 57
Reputation: 1571
This can be solved using regular expressions
String address= rs.getString("adress");
String[] addressPart =address.split("(?<=\\D)(?=\\d)");
Street.setText(addressPart[0]);
Number.setText(addressPart[1]);
Upvotes: 1