[Chicago-talk] REGEX question

Pete Krawczyk mongers at bsod.net
Fri Apr 16 19:03:47 CDT 2004

Subject: [Chicago-talk] REGEX question
From: Richard Solberg <flateyjarbok at yahoo.com>
Date: Fri, 16 Apr 2004 15:36:32 -0700 (PDT)

}$html = "exasperate"
}1) $html =~ /e(.*?)e/ # $1 = "xasp"
}2) $html =~ /.*e(.*?)e/ # $1 = "rat"
}I have a problem that would be solved if I could get
}an array filled with $array[0] = "xasp" and
}$array[1]="rat", $array[2] = third set of characters
}between 2 e's , $array[n] = .... until no more matches

I agree with what Mike had to say:

Subject: Re: [Chicago-talk] REGEX question
From: Mike Pastore <mike at oobak.org>
Date: Fri, 16 Apr 2004 18:24:21 -0500

} Have you tried using split?

but since TMTOWTDI, here's a hack for you:

perl -le '$a="exasperate"; (undef, at b)=($a=~m/(.*?)e/g); print join(",", at b)'

I never said it was pretty, efficient or good, but it gets the job done.

-Pete K

More information about the Chicago-talk mailing list