Regex to prevent whitespace at the front and end on a variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:07 AM
Hi, I am looking for the correct Regex to prevent a space at the start and end of a 'Single Line Text' variable. I have used the following:
^\S+$
But this allows a space at the start at end but NOT in the middle. I need to restrict a space at the start and the end but allow a space in the middle.
I have tried multiple different regex values to no avail. Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:20 AM
Hi @ashfaq ,
please use the below Regex key.
^\S(?:.*\S)?$
I hope this helps!
Regards,
Hemant
**Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.**