I think Gilles had another good idea with the [^[[:digit:]]]* to strip out all the leading non-digits instead of the first greedy .*<br><br>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 :)
<br><br>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.<br><br>Sean<br><br><div>
<span class="gmail_quote">On 5/9/07, <b class="gmail_sendername">Trevor Cordes</b> <<a href="mailto:trevor@tecnopolis.ca">trevor@tecnopolis.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 9 May, Sean Walberg wrote:<br>> The * operator is greedy, in perl .*? probably would have worked, I'm<br>> not sure if that feature exists in sed. Google around for<br>> "backtracking",<br><br>
Sean beat me to it. Perl's non-greedy *? is what you want. Without it<br>you're taking the most left-most first. I use perl's non-greedy<br>modifiers *all* the time. Plus, perl let's you use \d instead of the
<br>horrific posix [[:digit:]] syntax.<br><br>_______________________________________________<br>Roundtable mailing list<br><a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br><a href="http://www.muug.mb.ca/mailman/listinfo/roundtable">
http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>Sean Walberg <<a href="mailto:sean@ertw.com">sean@ertw.com</a>> <a href="http://ertw.com/">http://ertw.com/
</a>