Need a Regular expression Currency with decimal values

Deepika61
Tera Contributor

Hi All,

Actually i need regular expression that allows currency (numbers ) and as well as decimal values also

Currently i have regular expression that only allows numbers, so i need to decimal values also along with this

Deepika61_0-1701755486521.png

please help me to complete this 

Thanks

Deepika

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @Deepika61 

 

Can you try below : 

 

var reg = /^AUD\s\$(\d{1,5}(\.\d{1,2})?)$/;

if(reg.test('AUD $100.12')){
gs.print(true);
}

/*
^   : Start
AUD : Currency symbol
\s  : space after currency symbol
\$  : dollar sign
\d{1,5}  : upto 5 digit
(\.\d{1,2})? : optional decimal (two dogit)
*/

 

test it on background script

 

VishalBirajdar_0-1701756900488.png

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

1 REPLY 1

Vishal Birajdar
Giga Sage

Hi @Deepika61 

 

Can you try below : 

 

var reg = /^AUD\s\$(\d{1,5}(\.\d{1,2})?)$/;

if(reg.test('AUD $100.12')){
gs.print(true);
}

/*
^   : Start
AUD : Currency symbol
\s  : space after currency symbol
\$  : dollar sign
\d{1,5}  : upto 5 digit
(\.\d{1,2})? : optional decimal (two dogit)
*/

 

test it on background script

 

VishalBirajdar_0-1701756900488.png

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates