Regular Expressions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 07:54 AM
Hi All,
Can any one guide me how can we stop the users to entering the spaces on starting and ending of the string variables by using Regex. Need to allow single space in middle of the name like(Nagi Reddy).
Thanks,
Nagireddy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:35 AM
Hi there,
This should work:
^[^\s]+(\s+[^\s]+)*$
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:36 AM
Hi there,
This regex should work:
^[^\s]+(\s+[^\s]+)*$
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 11:29 AM
Hi @Mark Roethof ,
Thanks for your reply, that is working in the middle space of two words, and it's allowing us to enter the name with white space in starting.
Thanks,
nagireddy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 11:36 AM - edited 07-20-2023 11:36 AM
So thats good right? Or should the regex be completely the other way around?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field