- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:30 AM
Hi,
Need to write a regular expression that allows only numbers between 0 and 100 (including decimals).
Used !pattern1=/^[0-9.]*$/ && !pattern2=/^(?:100(?:\.0+)?|[0-9]?[0-9](?:\.[0-9]+)?)$/ but it's not working perfectly.
Any suggestions/solution.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:40 AM
@rahul gupta6 Please use the following regular expression instead.
/^(100(\.0{1,})?|(\d{1,2})(\.\d{1,})?)$/gm
You can test this expression at https://regex101.com/ with several combinations of integer and decimal values.
Please mark the response helpful and accepted solution if it manages to address your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:40 AM
@rahul gupta6 Please use the following regular expression instead.
/^(100(\.0{1,})?|(\d{1,2})(\.\d{1,})?)$/gm
You can test this expression at https://regex101.com/ with several combinations of integer and decimal values.
Please mark the response helpful and accepted solution if it manages to address your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:50 AM
Used this expression but still there is an issue that if alphabet value is entered in the field, it changes to 0. However, if anything more than 100 is entered, it changes to blank. Need to have it changed to blank in any case if the regex is not matched.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 07:02 AM
@rahul gupta6 It is not the issue of regular expression but your code. Could you please provide your code here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 09:16 AM
Never mind, changed the field type from decimal to string and it worked. Thank you for your assistance.