- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2020 07:28 PM
Trying:
var regexp = /Status:(.*)/g;
if (str.match(regexp)) {
str = str.match(regexp);
gs.log('*** ISSUE: strRegEx = ' + str);
var status = str.split(" ");
gs.log('*** ISSUE: Status = ' + status[1]);
Getting:
Information *** ISSUE: strRegEx = Status: Done (was: Testing)
Warning org.mozilla.javascript.EcmaError: Cannot read property "1" from undefined
Caused by error in sysevent_script_action.95636cdbdba1181072bea04913961902.script at line 10
7: str = str.match(regexp);
8: gs.log('*** ISSUE: strRegEx = ' + str);
9: var status = str.split(" ");
==> 10: gs.log('*** ISSUE: Status = ' + status[1]);
Information *** ISSUE: Status = undefined
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 05:10 AM
It looks like it's not able to split str, so forcing str to a string should do it
str = str.match(regexp).toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 06:11 AM
Here is the solution.
var str='Status: wlerkjwlkr';
var regexp = /Status:(.*)/g;
if (str.match(regexp)) {
str = str.match(regexp);
gs.print('*** ISSUE: strRegEx = ' + str);
var status = str.toString().split(" ");
gs.print('*** ISSUE: Status = ' + status[1]);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 06:49 AM
var regexp = /Status:(.*)/g;
add this line var k = str.match(regexp);
if (k.length != 0) // to check whether match is found or not.
{
str = str.match(regexp);
gs.log('*** ISSUE: strRegEx = ' + str);
var status = str.split(","); // change your line to this.
gs.log('*** ISSUE: Status = ' + status[1]);
}
Try this and let me know if this helps
Mark my ANSWER as CORRECT and HELPFUL if it helps