- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 10:48 PM
Hello!
I am working on a script to get the value between a string and a character. The sample is:
Name: firlas (Last Name, First Name)
The requirement is to get the value of "firlas". I tried creating a regex but it won't accept the character "(".
var regex = /(?:Name: )(.*)(?:()/g;
Please help!
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 11:01 PM
Hi @ceraulo ,
are you expecting only 'firlas' text from it. If yes try below
var name='Name: firlas (Last Name, First Name)';
var val=name.split(' (');
gs.info(val[0]);
var finalname=val[0].split('Name: ')
gs.info(finalname[1]);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 11:01 PM
Hi @ceraulo ,
are you expecting only 'firlas' text from it. If yes try below
var name='Name: firlas (Last Name, First Name)';
var val=name.split(' (');
gs.info(val[0]);
var finalname=val[0].split('Name: ')
gs.info(finalname[1]);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 11:54 PM
This works! Thank you.