How to write the regex to get the words before dot from 456yti.computer.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 08:59 AM
I have given an example expression above in the question but i want to get the characters before the dot for any expression.
- Labels:
-
Event Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 09:27 AM
Ankitha,
You want something like /^([a-z0-9]*)\./ suggest you try this on somewhere like regex101.com.
Hope this helps,
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 09:48 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2022 06:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 09:31 AM
Hi,
Your requirement can be achieved by using JavaScript split() method as well instead of using regex pattern as shown below.
var testText="firsttext.middletext.lasttext";
var array=test.split(".");
gs.print(array[0]);
if requirement can be achieved with Javascript methods then I would prefer Javascript methods over regex pattern.
I am adding this answer just in case someone finds it useful in future.
Thanks and Regards
Abhijit
Regards,
Abhijit
ServiceNow MVP