Results 1 to 4 of 4
- 01-03-2011, 02:17 PM #1
Member
- Join Date
- Nov 2010
- Location
- Johannesburg
- Posts
- 23
- Rep Power
- 0
How to use the split method with a non-constant delimiter
Good day,
I'm trying to read a text file by extracting specific data that are in one line and excluding others on the same line. The data I want to extract are separated by the 'space' delimiter but unfortunately this delimiter was not used uniformly for the entire line, I mean that sometimes data in a line will be separated by a single space for some and sometimes two to three spaces for others.
How do I change the delimiter for the split method I'm using please so that no matters the space between the data it extracts the correct ones?
Thanks
- 01-03-2011, 02:38 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 01-03-2011, 03:09 PM #3
Senior Member
- Join Date
- Dec 2010
- Posts
- 165
- Rep Power
- 3
you can use use "<space><space>*", if you really want space and left others like tabs alone. Otherwise, if you want tabs (and other whitespaces) to be counted as spaces, use "\\s+"
- 01-03-2011, 03:48 PM #4
Member
- Join Date
- Nov 2010
- Location
- Johannesburg
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
String split method
By DavidG24 in forum New To JavaReplies: 5Last Post: 12-14-2010, 02:01 PM -
String split method
By counterfox in forum New To JavaReplies: 2Last Post: 11-12-2010, 11:06 PM -
Please help me with Split method> String
By javanew in forum New To JavaReplies: 5Last Post: 04-02-2010, 06:15 PM -
split method problem
By javanew in forum New To JavaReplies: 1Last Post: 04-02-2010, 05:50 PM -
problem with split method
By abhiN in forum New To JavaReplies: 7Last Post: 02-10-2009, 01:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks