
japhy
Enthusiast
Mar 6, 2000, 6:22 AM
Post #3 of 5
(333 views)
|
|
Re: help please, search and replace with sequential numbers
[In reply to]
|
Can't Post
|
|
Your pattern doesn't work because after the first replacement, there IS no 7 in your string. You may want to use the \d regex metacharacter, which means "any digit character": <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $string = "100 apples\n"; $start = 3; while ($start < 15) { # change the FIRST occurrence of digits # to whatever $start holds $string =~ s/\d+/$start/; print $string; $start++; } </pre><HR></BLOCKQUOTE>
|