Jump to content

RegEx numbers at end of string


Recommended Posts

I am looking for help with a StringRegExpReplace function that only grabs the numbers plus a "." and "%"

currently I have "[^0-9.%]" which mostly works, but I and looking to only to match if it is at the end of the string.

Example string:  "DW-4 2.50%"

my expression also leaves the preceding "4"

I have tried using $ \b \z and a few others with no success.

Any suggestions?

Link to comment
Share on other sites

i am not specialist for  regexp  , (you know a maxim ? ...... A programmer has a problem. He decides to solve it using regular expressions. Now he has two problems. )

somthing like this    -(.*?)%

and when call array  add %

 

Link to comment
Share on other sites

@FrancescoDiMuro

Your expression allows 5.% - which is inconsistent ;)
Please try this

#Include <Array.au3>

$s = "Ford Prius 1%" & @crlf & _ 
    "DW-4 6.66% test" & @crlf & _ 
    "DW-4 6.%" & @crlf & _ 
    "DW-4 2.50%" & @crlf & _ 
    "Cotton Candy Non Circus7.5%" & @crlf& _ 
    "Francos Absolute .5%" 

$res = StringRegExp($s, '(?m)((?:\d*\.?\d+)%)$', 3)
_ArrayDisplay($res)

 

Edited by mikell
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...