Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regexp construction

807588Mar 1 2009 — edited Mar 4 2009
Hi,

I am trying to "filter" a string of the following form:

//some text before
Drives
*********
cdr LITEON DVD-ROM LTD163 GDHA
cdr HL-DT-ST CD-RW GCE-8400B B104

Msg
*********
//some more text here

From this string I am trying to get the following 2 strings:

1. "LITEON DVD-ROM LTD163 GDHA"
2. "HL-DT-ST CD-RW GCE-8400B B104"

I tried to use the following regexp:
p = Pattern.compile("cdr\\s*([\\w\\p{Punct}]*)\\s*([\\w\\p{Punct}]*)\\s*([\\w\\p{Punct}]*)\\s*([\\w\\p{Punct}]*)\\s*(?:Msg)");
m = p.matcher(str_input);
However, if I try this, it only returns the first string and not the second.
(I am new to regexps and still trying to read up on this topic).
Any advice or help on what I am doing wrong here would be appreciated.

thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2009
Added on Mar 1 2009
18 comments
209 views