function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RangaRayapatiRangaRayapati 

Need regular expression to allow $ % . and Numbers in text

Hi,

I need a regular expression for the below formats allowing in text box in validation rule.

$100
200$
25%
0.25

User can directly enter the amount in doller or decimal values lessthan 1 or percentage values lessthan 100 for the discount

Please provide an regular expression to allow above formats.

Thanks in advance!
Suraj Tripathi 47Suraj Tripathi 47
Hi Ranga Rayapati,
Greetings!

Please use the regular expression given below-
String regex = '^[0-9%$]+$'
Here ^ is the starting symbol and $ is the ending symbol.

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi
 
RangaRayapatiRangaRayapati
Hi Suraj Tripathi,

Thanks for response!

Now allowing both the %$ both at time I need restrict that too, need to allow below format only.
$100
200$
25%
0.25

I am trying to write like below, but not working. Can you plaese guide me.
OR(
NOT(REGEX(Discounts__c , "^[0-9$]+$")),
NOT(REGEX(Discounts__c , "^[0-9%]+$")),
NOT(REGEX(Discounts__c , "^[0-9]+$")),
)

Thanks