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

Popular posts from this blog

python - Setting ctypes.Structure default values -

Ansible - ERROR! the field 'hosts' is required but was not set -

java - HTTP Status 500 - No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode -