#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Regex for money values help


    I am trying to get a regex to get values like:

    $28.0k
    $2.8k
    $5.2M

    I want the whole string in a variable not just the number i need the $ and the M or k included.

    I am currently trying
    Code:
    my $value = $data =~ m/(\\\$\d+\.\d+M|k)/;
    but this doesn't seem to be getting the correct value, all help is appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    843
    Rep Power
    496
    Hi,

    try something like this:

    Perl Code:
    my $value = $1 if $data =~  m/(\$\d+\.\d+[kM])/;

IMN logo majestic logo threadwatch logo seochat tools logo