[sf-perl] regex help

Jeff Bragg jackofnotrades at gmail.com
Tue Oct 11 12:16:31 PDT 2011


On Tue, Oct 11, 2011 at 12:00 PM, Steve Fink <sphink at gmail.com> wrote:

> ...
> Option 2:
>
> my ($sentence) = /^(?:\s*\d+\.\s*)?(.*)/;
>
> or if you want to strip whitespace from the beginning of non-numbered
> lines as well:
>
> my ($sentence) = /^\s*(?:\d+\.\s*)?(.*)/;
>

+1 for this solution, as it doesn't assume numbers/spaces at the beginning
of each line; the OP's post made it sound like their presence wasn't
guaranteed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20111011/f4d01267/attachment.html>


More information about the SanFrancisco-pm mailing list