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.&nbsp; .*? does work wonders too, but regexps written that way suffer from the &quot;what the heck does this do?&quot; 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&#39;ve gone through, and is a good sign to rethink the way you&#39;re matching.<br><br>Sean<br><br><div>
<span class="gmail_quote">On 5/9/07, <b class="gmail_sendername">Trevor Cordes</b> &lt;<a href="mailto:trevor@tecnopolis.ca">trevor@tecnopolis.ca</a>&gt; 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&nbsp;&nbsp;9 May, Sean Walberg wrote:<br>&gt; The * operator is greedy, in perl .*? probably would have worked, I&#39;m<br>&gt; not sure if that feature exists in sed.&nbsp;&nbsp;Google around for<br>&gt; &quot;backtracking&quot;,<br><br>
Sean beat me to it.&nbsp;&nbsp;Perl&#39;s non-greedy *? is what you want.&nbsp;&nbsp;Without it<br>you&#39;re taking the most left-most first.&nbsp;&nbsp;I use perl&#39;s non-greedy<br>modifiers *all* the time.&nbsp;&nbsp;Plus, perl let&#39;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 &lt;<a href="mailto:sean@ertw.com">sean@ertw.com</a>&gt;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://ertw.com/">http://ertw.com/
</a>