in reply to Re: Parsing Regex
in thread Parsing Regex

The method in the post above worked. I'm guessing this is my best option, since it seems I can't do this all in one regex (to my knowledge thus far).

For those viewing the thread, the method is to substitute (subtract) the date portion from the string, and then use the remaining:
$date = _trim($1) if $line =~ s/.*(\d{2}\/\d{2}\/\d{4})//; $address = _trim($1) if $line =~ /(.*)/;

Replies are listed 'Best First'.
Re^3: Parsing Regex
by GrandFather (Saint) on Sep 23, 2009 at 20:25 UTC

     if $line =~ /(.*)/ is redundant. The capture matches the whole string and the match always succeeds (even when $line is undef). Instead just use $address = _trim($line), or $address = _trim($line) if defined $line if $line can be undefined.

    The .* in s/.* is important because it deletes any junk before the date along with the date, leaving just the address for the following code.


    True laziness is hard work