For a number such as 243210890000, the non greedy {1,5} grabs the least it can, the 9, correct? I do want the {1,5} to grab as many as it can, up to 5 digits, but I don't want it grabbing any of the trailing zeros. Examples of what I want:
Input $1
28400300 84003
100 1
As it stands, if the input is "10" the {1,5} grabs itself some zeros, and I want those zeros to go into the 0* (I don't want 'em captured).
I've rewritten the regex so that it matches "(zero to four digits, one non-zero digit) and then the 0*" but the issue got me curious to see if there was some way you could make the right-most greedy construct "beat out" one to its left.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|