- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 09:36 AM
Can somebody please help me with validation Regex that accepts or allows uppercase letters, numbers, space, and special characters only such as: !@#$%&*_-,
How can I achieve this please? Thanks for your continuous support.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:34 AM
Try the below regex:
/^[A-Z0-9 !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+$/g
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:34 AM
Try the below regex:
/^[A-Z0-9 !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+$/g
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 09:41 AM
@debendudas Thanks, this works.
Although, I had to edit it by removing the first character "/" and the last two characters "/g" to make it suite and work based on my requirement. Just saying this for anyone who might want to use this solution in the future. Once again, thanks so much @debendudas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:45 AM
Hello @ID NOBLE
ServiceNow provides out-of-the-box (OOTB) solutions for regex validation without requiring custom scripting.
Create a new record in Question Regular Expressions(question_regex) table with following configuration:
Add this regex to catalog variable
When an invalid input is entered, an error message is shown.
Just modify the regex to ^[A-Z0-9!@#$%&*_\-\s]*$ to add the special character and white space.
Additionally, to make the alphabets and numbers mandatory the regex can be modified to ^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9!@#$%&*_\-\s]*$
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar