in reply to Regex hackery
But apart from that, I have a few minor suggestions on your regex.
Rewritten, it would read:
After this, your file name is $1, and your size is, as you stated, $2$3./ ^ [^.]+ \. \s # Ignore the line numbers (.+?) # Capture the file name (?: (\d) \s # Capture the optional leading size digit ) ? ( \d+ \. \d {2} # Capture the rest of the size ) \s MB .* $ /x
And yes, there is an ambiguity, where if the line was:
The regex would parse "go" as the file name and "2123.45" as the file size. There's no way around this given the format of the input.1. go 2 123.45 MB
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex hackery
by ikegami (Patriarch) on Jun 12, 2009 at 18:46 UTC |