String input = "DATA,{23.11,58.25},{23,33,43},{20070705,20070805}";
String[] splitLine = input.split(",{");
doesn't work. I've tried escaping the { by using
String[] splitLine = input.split(",\{");
but Eclipse tells me that { is not an escapable character.
Anybody have a suggestion???
Thanks!
SadRed - 17 Apr 2007 04:26 GMT
On Apr 17, 12:10 pm, sciflu...@gmail.com wrote:
> String input = "DATA,{23.11,58.25},{23,33,43},{20070705,20070805}";
>
[quoted text clipped - 9 lines]
>
> Thanks!
String[] splitLine = input.split(",\\{"); // regex engine gets ",\{"
Daniel Pitts - 17 Apr 2007 07:54 GMT
On Apr 16, 8:10 pm, sciflu...@gmail.com wrote:
> String input = "DATA,{23.11,58.25},{23,33,43},{20070705,20070805}";
>
[quoted text clipped - 9 lines]
>
> Thanks!
"\n" create a string with a newline, not a \ and then an n
"\\n" create a string with a single slash, and then an n.
The regex engine needs to parse a string, and it thinks that { is a
special charactor.
To tell the regex enginer that you want the literal {, you have to put
a \ before it in the string.
To get the \ before it in the string, you have to tell the Java
compiler to espace the \
Therefore what you want is "\\{".
Hope this verbose explaination helps cement the concept :-)
Daniel.
Lars Enderin - 17 Apr 2007 09:21 GMT
Daniel Pitts skrev:
> On Apr 16, 8:10 pm, sciflu...@gmail.com wrote:
>> String input = "DATA,{23.11,58.25},{23,33,43},{20070705,20070805}";
[quoted text clipped - 22 lines]
>
> Hope this verbose explaination helps cement the concept :-)
You can often use [] to quote a special character: ",[{]".
scifluent@gmail.com - 17 Apr 2007 17:44 GMT
Thank you for all of your suggestions, both verbose and terse! I am
back on track!