[PLUG] Long Perl regex...
Jeff Schwaber
freyley at gmx.net
Thu Sep 18 13:39:02 UTC 2003
On Thu, 2003-09-18 at 13:20, Wil Cooley wrote:
> On Thu, 2003-09-18 at 13:06, Jeff Schwaber wrote:
>
> > Or, in a readable language, and without using regexes:
> >
> > #!/usr/bin/python
> > # get your string from somewhere, save it in variable line
> >
> > i=0, end=-1, numbers=""
> > while i < 6:
> > if line[end] != " ":
> > numbers = numbers + line[end]
> > i = i + 1
> > end = end - 1
> >
> > Of course, you never said anything about this either running incredibly
> > quickly (this is okay, but poky compared to a regex) or that spaces were
> > the only non-numeric characters in the midst of those numbers. Plus you
> > wanted to put it in a bash script.
> >
> > But I'm just having fun. =)
>
> It's faster to do a join on a list than to concatenate strings, if
> you're doing it a lot.
>
> Wil
yeah, that's true.
Jeff
More information about the PLUG
mailing list