Match fraction number javascript

1

I have a script and in one of the lines:

return $flag.text().match(/[0-9 ]+(?=\%)/i);

read the numbers of a tag p .

Ex:

<p>Desconto 15%</p> 

In case it will read the number 15.

From what I know this line does not read the number with a semicolon ex: 9,09 or 9,09% with%.

In this example if it reads only up to the comma, how would I make this script read the numbers after the comma?

    
asked by anonymous 22.01.2015 / 12:52

1 answer

2

You only need to add . and , to the expression thus leaving /[0-9,\.]+(?=\%)/ . The i f modifier is not required in this situation.

Fiddle

    
22.01.2015 / 12:57