in reply to Regexp to extract groups of numbers

My thanks to everyone for the advice on unpack. The perldoc is in front of me as I speak.

Now back to my corner
Neil

  • Comment on Re: Regexp to extract groups of numbers

Replies are listed 'Best First'.
Re^2: Regexp to extract groups of numbers
by davido (Cardinal) on Feb 07, 2005 at 03:42 UTC

    Another comment...

    When deciding between the use of unpack versus a regular expression with capturing, there isn't exactly a hard fast rule. But a good rule of thumb is this: If you're picking things out based on character position, use unpack, and if you're picking things out based on a sequence or pattern, use pattern matching (a regular expression). As it happens, regular expressions are flexible enough to handle both width-formatted data and pattern formatted data, but sometimes it's just better to use an actual screwdriver rather than the funky one that's part of a 200-tool swiss army knife. ;)

    Oh, and split is a whole other option, most ideally suited for pattern-delimited data.


    Dave