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!

Scanner, comma delimiter and regular expression

807603Jan 12 2008 — edited Jan 15 2008
Hi java lovers,

I'm new to regular expression and having some trouble with that. Here is the story:
I have a String like this: 01,0034564,20080108,"William Wallace, Mr.","Percetakan Negara IXA, No. 33",3090000
I want to get each value which are delimited by comma ",", result shall be like this:
01
0034564
20080108
William Wallace, Mr.
Percetakan Negara IXA, No. 33
3090000

Using Scanner class and invoking useDelimiter(",") absolutely will give unexpected result, since we can use Pattern or String with regular expression on useDelimiter() method, what is the regular expression syntax so the Scanner class will give my expected result?

thanks !
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2008
Added on Jan 12 2008
18 comments
566 views