Answer the question
In order to leave comments, you need to log in
How to cut a string with a regular expression?
Good afternoon! There is a line
String valueUrl = getPage(" api.vk.com/method/database.getRegions?&country_id=1 ");
the cat contains the answer:
{"response":[{"region_id":"1000001","title":"Адыгея"},{"region_id":"1121540","title":"Алтай"},{"region_id":"1121829","title":"Алтайский край"},{"region_id":"1123488","title":"Амурская область"},{"region_id":"1000236","title":"Архангельская область"},
Answer the question
In order to leave comments, you need to log in
If you really want a regular expression, then you can do something like:
String s = "та самая строка";
// коды
Matcher m = Pattern.compile("\"region_id\":\"(\\d+)\"").matcher(s);
while (m.find()) { m.group(1));}
// названия
Matcher m2 = Pattern.compile("\"title\":\"([^\"]+)\"").matcher(s);
while (m2.find()) { m2.group(1));}
You receive data in JSON format. use any JSON reader for your PL and it will be much easier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question