Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: String regex replacement

by hdb (Prior)
on Feb 24, 2014 at 09:15 UTC ( #1075956=note: print w/ replies, xml ) Need Help??


in reply to String regex replacement

What you describe, sounds like rounding down to the next 1000s. Have a look at this example:

use strict; use warnings; my @numbers = ( 500, 988, 1210, 1300, 2134, 2500 ); # rounding numerically for (@numbers) { my $n = int( $_/1000 )*1000; print "$_ => $n\n"; } # rounding in regex for (@numbers) { s{(\d+)}{int( $1/1000 )*1000}e; print "$_\n"; }


Comment on Re: String regex replacement
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1075956]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-09-23 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (219 votes), past polls