Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegExp Help

Status
Not open for further replies.

LucL

Programmer
Jan 23, 2006
117
US
Hey Guys,

I'm trying to extract the individual columns returned by an FTP server on a "dir" call which lists files and directories in the path.

The fields are divided using spaces, but I don't know how to seperate them out (if there is a way to do this).

Sample output:

-rw-rw-rw- 1 root root 1002893 Jan 24 19:07 13(1).wmv.FLV
-rw-rw-rw- 1 root root 973448 Jan 24 19:07 13(2).wmv.FLV
-rw-rw-rw- 1 root root 582040 Jan 24 19:07 13(3).wmv.FLV
-rw-rw-rw- 1 root root 6135869 Jan 24 19:08 13(4).wmv.FLV
-rw-rw-rw- 1 root root 370270 Jan 24 19:08 13(5).wmv.FLV
-rw-rw-rw- 1 root root 978788 Jan 24 19:08 13(6).wmv.FLV
-rw-rw-rw- 1 root root 302864 Jan 24 19:08 13(7).wmv.FLV
-rw-rw-rw- 1 root root 863366 Jan 24 19:07 13.wmv.FLV
-rw-rw-rw- 1 root root 277817 Jan 24 19:09 14(1).wmv.FLV
-rw-rw-rw- 1 root root 302864 Jan 24 19:09 14(2).wmv.FLV
-rw-rw-rw- 1 root root 4249088 Jan 24 19:10 14(3).wmv.FLV
-rw-rw-rw- 1 root root 885311 Jan 24 19:10 14(4).wmv.FLV

I need the permissions "-rw-rw-rw", the owner "root", size "xxxxx", mod_date, etc but know of no easy way to parse that data since the amount of spaces varies based on the output for each line.

In PHP, the pgrep_split function does the trick ($current = preg_split("/[\s]+/",$row,9) ) but I don't know of an equivelent in Java.

Thanks!
Luc L.
 
Thanks!

Didn't realize you could use regexp in split.

Learn something new ever day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top