18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Pattern for matching 276,50
globalworming
Moderators
Hi all
I want to capture some prices in form of "X.XXX,XX", but just the numbers, so I tried a regular expression like this:
Any help on this very appreciated
Regards
Wormi
I want to capture some prices in form of "X.XXX,XX", but just the numbers, so I tried a regular expression like this:
var $priceString = "276,50";
$priceString.match("[0-9]+(?=\,)[0-9]{2}") // null
$priceString.match("[0-9]+\,[0-9]{2}") // captures 276,50, but how do i get rid of the ','
Any help on this very appreciated
Regards
Wormi
Comments
To get just the numbers, you could do
$priceString = $priceString.replace(/[^0-9]/g, '');
It matches all non number characters and replaces with blank.
If you want the real number from the string (with decimals) you could do
var $price = parseFloat($priceString.replace(/,/, "."));
Regards,
Narayan
thanks a lot, it's working fine. I'm not very sophisticated using Regular Expressions, but replacement is the next chapter in my JavaScript Guide.