Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

regex for dollar amount including sign

Kumar38
Kilo Sage

Hi,

I need to have a regex validation on a variable that Should accept dollar ammounts like $20.01 etc.

I used this  /^\$(?![.0]*$)\d+\.\d{2}$/ , but it accepts only 20.01 as a valid input , I would like it to accept dollar sign too

1 ACCEPTED SOLUTION

@Kumar38 

 

Try this '(\$[0-9]+(.[0-9]+)?)' and let me know if it didn't worked. 

 

Please mark the answer as helpful if it helped you accordingly!

 

Thanks,

Hari

View solution in original post

4 REPLIES 4

Hari Prasath
Tera Guru

Hi @Kumar38 ,

 

You can try using this regex /^[0-9.,]+$/ . Please let me know if it didn't worked. 

 

Please mark the answer as helpful if it helped you accordingly!

 

Thanks,

Hari

It Says not a valid update , when I put this in "Question Regular Expression"

@Kumar38 

 

Try this '(\$[0-9]+(.[0-9]+)?)' and let me know if it didn't worked. 

 

Please mark the answer as helpful if it helped you accordingly!

 

Thanks,

Hari

thank you this one without the ' ' worked... šŸ™‚