stringtokenizer that traps ASCII linebreaks

W

wnstnsmith

Dear all,

How do i define a stringtokenizer that traps chr13, chr10 combinations?

tia
WS
 
A

Adam Jenkins

Dear all,

How do i define a stringtokenizer that traps chr13, chr10 combinations?

tia
WS

You can't exactly do this with StringTokenizer, since it doesn't support
splitting on specific multi-char patterns. You could say

StringTokenizer stok = new StringTokenizer(string, "\r\n");

which would split "string" at each \013\010, but it would also split on
just a \013 or \010 or \013\013, etc. If you really need to split at
each \r\n, then you can use String.split, as in

String[] tokens = string.split("\r\n");

Adam
 
W

wnstnsmith

Thanks very much indeed, that does it. Guess my mistake was to have the
tokenizer look for '\r' + '\n' + "blablabla", instead of "\r\n". You can
imagine that had me wondering...

WS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top