How to extract text from quoted string with regex in java? -
i have string this:
"0008934","1801 w normatown road","romeoville","il","us","60446","8158866981","y"
i extract values inside double quotes. please me accomplish task.
this expecting:
0008934 1801 w normatown road romeoville il 60446 8158866981 y
anyone can pleas me?
you can this:
import java.util.regex.pattern; import java.util.regex.matcher; public class regextest { public static void main(string[] args) { string strinput = "\"0008934\",\"1801 w normatown road\",\"romeoville\",\"il\",\"us\",\"60446\",\"8158866981\",\"y\""; pattern pattern = pattern.compile("\"([^\"]*)\""); matcher matcher = pattern.matcher(strinput); while (matcher.find()) { system.out.println(matcher.group(1)); } } }
output:
0008934 1801 w normatown road romeoville il 60446 8158866981 y
Comments
Post a Comment