Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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"; }

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 browsing the Monastery: (8)
As of 2016-06-24 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (322 votes). Check out past polls.