APM: Regular Expression Question

Zach Vonler zvonler at gmail.com
Wed Aug 16 08:41:47 PDT 2006

On 8/16/06, Jay Flaherty <jayflaherty at gmail.com> wrote:
> $piece =~ s/\t{0,3}/\"\t\"/g;

There are two problems with this one, the first being that you have
the ability to match on a null string, and the second being that
whatever does get matched is replaced by only a single "\t".

If the number of fields you want to modify is in $count, something like

$repl = "\\\"\\t\\\"" x $count;
$piece =~ s/\t{$count,$count}/$repl/;

might get you most of the way there.  Note of course that it does not
modify inputs with fewer than $count fields.


More information about the Austin mailing list