Regular Expressions

Nagireddy3
Tera Contributor

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

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

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

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

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

LinkedIn

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

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

LinkedIn