java - Extracting string data present in single quote -


i using java 7, , have data stream containing following line:

sender='caltrans' sender='bigo' sender='fio' .. .. 

i extract data present in single quote. i.e.

caltrans bigo fio 

... ..

any suggestion regular expression?

you use regex:

^sender='([^']+)'$ 

with multiline flag. regex matches beginning of line, followed text sender=', followed not single quote, followed single quote, followed end of line.

string regex = "(?m)^sender='([^']+)'$"; 

so, print of matches capturing group 1, this:

pattern p = pattern.compile( regex); matcher m = p.matcher(inputtext); // inputtext = "sender='caltrans'... etc" while(m.find()) {     system.out.println(m.group(1)); } 

Comments