aa: { one: "hello", two: "good", three: "bye", four: "tomorrow", }, "bb": { "1": "a quick fox", "2": "a slow bird", "3": "a smart dog", "4": "a wilf flowert", my data above want select text within "" on right side of : , including "" marks
what is
: ("(.*?)") but select : isn't want.
if must use regular expression, can try matcher.group() method found here.
public class testclass { public static void main(string[] args) { string input = "aa: {\n" + " one: \"hello\",\n" + " two: \"good\",\n" + " three: \"bye\",\n" + " four: \"tomorrow\",\n" + " },\n" + " \"bb\": {\n" + " \"1\": \"a quick fox\",\n" + " \"2\": \"a slow bird\",\n" + " \"3\": \"a smart dog\",\n" + " \"4\": \"a wilf flowert\",\n"; // actual code need pattern pattern = pattern.compile("(: )(\".+\")"); matcher match = pattern.matcher(input); while (match.find()) { // here go, value without : string value = match.group(2); system.out.println("found 1 = " + value); } } } this results in following me:
found 1 = "hello" found 1 = "good" found 1 = "bye" found 1 = "tomorrow" found 1 = "a quick fox" found 1 = "a slow bird" found 1 = "a smart dog" found 1 = "a wilf flowert"
Comments
Post a Comment