[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Trying to add products using non-numeric quantities...
s/(^=)|\D/$1/g;
Enjoy.
Steffen Dettmer wrote:
>
> * Jeff Carnahan wrote on Thu, Jun 28, 2001 at 09:51 -0700:
> > } You want this w/o the if? I think you can write:
> > }
> > } @quantities = map { s/(^=)?\D/$1/g; $_ }
> > }
> > } or better:
> > }
> > } @quantities = map { s/[^\d=]//g; $_ }
> > }
> > } or maybe faster like:
> > }
> > } #delete unknown (==not 0-9,=) chars and map something(?):
> > } @quantities = map { tr/0-9=//cd; $_ }
> > }
> >
> > The problem was, if the first character is an equals sign,
> > ignore it and strip all non-digits past that FIRST equals sign.
> > ie: "=1=4" should be "=14"
>
> You mean, ignore any "=" except the first?
>
> > Of course, that first equals sign is optional, and may not
> > occur at any other location, so "=1a1" should be "=11", "1a=14"
> > should be "114", etc.
>
> I see, not trivial... Let's try:
>
> "m/^(=)?/, tr/0-9//cd, $_ = $1 . $_" as expression
>
> in out
> =1=4 =14
> 1=4 14
> =1a1 =11
> 1a=14 114
> =1a=14 =114
> =1=2= =12
>
> Tested with:
>
> perl -e '$_ = $ARGV[0];
> m/^(=)?/, tr/0-9//cd, $_ = $1 . $_;
> print "$_\n";' =1=2=
>
> (for you copy and paste test)
>
> Well, very similar to your thing, maybe not so nice to read,
> maybe a little faster but I think nearly the same :) Sorry, but I
> missed the requirements first :)
>
> oki,
>
> Steffen
>
> --
> Dieses Schreiben wurde maschinell erstellt,
> es trägt daher weder Unterschrift noch Siegel.
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users
--
Mark Johnson
Senior Systems Architect - Professional Services
Red Hat, Inc.
E-Business Solutions
markj@redhat.com
703-456-2912