|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2011-02-27 08:11, David Gibbs wrote:
On 2/26/2011 5:29 PM, Pete Hall wrote:
Why does this work:
String[] fields = errRecord.replace("|", "\t").split("\t");
While this does not:
String[] fields = errRecord.split("|");
Isn't '|' a regex operator?
Have you tried escaping the |? ("\|")
david
Yeah, tried that. It throws an exception if I ignore the editor error:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\).
I've tried "\0x7c", "\u007C" and "\u7C00" too. The editor accepts those,
but they all return an array of String containing one element, which
includes all of the characters in the record, including the pipes. I
copied the pipe character from the variable window into V (hex viewer),
and it really is 0x7c. I even tried extracting the pipe from the record
with substring() and using the extracted delimiter in split(). It made
no difference.
An example errRecord looks like this:
1|20110226||||0|6068|6|33243.95|6062|35084323.55|0|0.00|0|0.00
I guess I'll just go with the two stage parse. Apparently split() has
some limitations.
- -- Pete Hall
pete@xxxxxxxxxxxxxx
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk1qd1oACgkQXczQcKdXKg4SJwCgtUjD+TJMFYfWOMHrGSqyZWSL
DYIAnjRaEGMDHha7RcF3o5JnZpndORZ5
=Z6tI
-----END PGP SIGNATURE-----
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing
list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.