- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2024 01:57 PM - edited ‎12-19-2024 01:58 PM
Hello All,
I need a help where i want to get the first half and second half of a value from a string from an output.
Example:
I have a variable name= abc.hgl.knl;
i want the output as abc_need_to change.hgl.knl where i need to insert a custom string inbewteen the abc and hgl.
Any helpful answers will be appreciated.
Thanks
Sai
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2024 02:07 PM
If you mean the variable has the value of abc.hgl.knl and you want to change the value to something like abc_need_to change.hgl.knl, strictly following this format you can split on the period, append the first element, then rejoin:
var myString = 'abc.hgl.knl';
var myNewString = '_need_to change';
var myStringArr = myString.split('.');
myStringArr[0] += myNewString;
myString = myStringArr.join('.');
gs.print(myString);
You can combine a few of these lines - I showed each to make it easier to follow...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2024 02:07 PM
If you mean the variable has the value of abc.hgl.knl and you want to change the value to something like abc_need_to change.hgl.knl, strictly following this format you can split on the period, append the first element, then rejoin:
var myString = 'abc.hgl.knl';
var myNewString = '_need_to change';
var myStringArr = myString.split('.');
myStringArr[0] += myNewString;
myString = myStringArr.join('.');
gs.print(myString);
You can combine a few of these lines - I showed each to make it easier to follow...