regex - java regular expression for String surrounded by "" -
i have:
string s=" \"son of god\"\"cried out\" day , ok "; this shown on screen as:
"son of god""cried out" day , ok pattern phrasepattern=pattern.compile("(\".*?\")"); matcher m=phrasepattern.matcher(s); i want phrases surrounded "" , add them arraylist<string>. might have more 2 such phrases. how can each phrase , put arraylist?
with matcher you're 90% of way there. need #find method.
arraylist<string> list = new arraylist<>(); while(m.find()) { list.add(m.group()); }
Comments
Post a Comment