How to extract a particular string from a given Sentence

Vidya Lakshmi
Kilo Sage
Kilo Sage

Hi All,

I need to extract the below words from the given fixed format(Sentence) and store it in a variable

LineWalk - RequestedFor(VIDYALAK@abc.com) -  OpenedBy(MANOJBAN@abc.com)

Var A should contain LineWalk

Var B should contain VIDYALAK@abc.com

Var C should contain MANOJBAN@abc.com

Please help me how to extract the data.

 

Regards,

R Vidya Lakshmi

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello Vidya,

Please check with below script once in background script:

var sentenceValue = "LineWalk - RequestedFor(VIDYALAK@abc.com) -  OpenedBy(MANOJBAN@abc.com)";
var sentenceArray = sentenceValue.split(" - ");
var variableA = sentenceArray[0];
var variableBValue = sentenceArray[1].split("(")[1];
var variableCValue = sentenceArray[2].split("(")[1];
var variableB = variableBValue.substring(0, variableBValue.length-1);
var variableC = variableCValue.substring(0, variableCValue.length-1);
gs.print(variableA);
gs.print(variableB);
gs.print(variableB);

If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful.

Thanks

View solution in original post

1 REPLY 1

Mahendra RC
Mega Sage

Hello Vidya,

Please check with below script once in background script:

var sentenceValue = "LineWalk - RequestedFor(VIDYALAK@abc.com) -  OpenedBy(MANOJBAN@abc.com)";
var sentenceArray = sentenceValue.split(" - ");
var variableA = sentenceArray[0];
var variableBValue = sentenceArray[1].split("(")[1];
var variableCValue = sentenceArray[2].split("(")[1];
var variableB = variableBValue.substring(0, variableBValue.length-1);
var variableC = variableCValue.substring(0, variableCValue.length-1);
gs.print(variableA);
gs.print(variableB);
gs.print(variableB);

If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful.

Thanks