Regex to trim white space and special characters from an input string before submission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 03:39 AM
Hi Team,
There is a requirement to trim white spaces and special characters from an input string before it gets submitted.
Ex. If user is inputting space in beginning and after the text ends and more than one space in between then it should get trimmed.
<space><space><space><tab>TEST<space>TEST1<space><space><tab>TEST2<space><space><space>
should become
TEST<space>TEST1<space>TEST2 ( With only one space in between )
Moreover only these characters could be allowed : ( ) & - (brackets, ampersand and hyphen) and no other characters
Ex. TEST - TEST1
TEST & TEST1
(TEST)
It will be great if someone could help me with the regex logic.
Regards,
Saurabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 10:12 AM