I think Gilles had another good idea with the [^[[:digit:]]]* to strip out all the leading non-digits instead of the first greedy .*
Most often I find that if I start a regexp with .* it can be rewritten much more simply by rethinking, often ending up in a [^X]*([X]+) pattern like Gilles or the s/[^X]//g pattern like I did. .*? does work wonders too, but regexps written that way suffer from the "what the heck does this do?" syndrome 6 months down the road :)
That said, having two .* in the same pattern usually ends up causing problems because of the very reasons we've gone through, and is a good sign to rethink the way you're matching.
Sean
On 9 May, Sean Walberg wrote:
> The * operator is greedy, in perl .*? probably would have worked, I'm
> not sure if that feature exists in sed. Google around for
> "backtracking",
Sean beat me to it. Perl's non-greedy *? is what you want. Without it
you're taking the most left-most first. I use perl's non-greedy
modifiers *all* the time. Plus, perl let's you use \d instead of the
horrific posix [[:digit:]] syntax.
_______________________________________________
Roundtable mailing list
Roundtable@muug.mb.ca
http://www.muug.mb.ca/mailman/listinfo/roundtable