I want to have a regex expression for excluding spaces and new line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 07:50 AM
I want to have a regex expression which will include all characters but not new line and spaces.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 07:58 AM
Hello @Taaha M,
Please refer to the link below:
https://www.servicenow.com/community/itsm-forum/need-a-regex-to-allow-all-characters-and-spaces-but-...
If it is helpful, please mark it as helpful and accept the correct solution, In future by refer to this solution it will helpful to them.
Thanks & Regards,
Abbas Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 08:11 AM
Hi @Taaha M ,
You can use this regex: /[\s\n]+/g
Here is an example of this regex to modify a sentence which has spaces and new line:
var sentence = "This is a sentence with spaces and \n New lines";
var modifiedSentence = sentence.replace(/[\s\n]+/g, "");
gs.log(modifiedSentence);
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!