My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Regex to avoid specific special characters

Sriram Karthick.G's photo
Sriram Karthick.G
·May 6, 2020

Need a regular expression that should avoid a specific string or all string which are having below mentioned symbols

Special character to avoid:

  1. Colon (:)
  2. Double forward slash (//)
  3. Dot (.)
  4. Question Mark (?)
  5. Ampersand (&)
  6. Equal To (=)
  7. Single forward slash (/)

Note:

  • Only symbols used in the URL pattern should be validated/avoided.
  • Other than that all other symbols are accepted
  • Regex should be working in javascript specifically