Extract value from the text

Vinay49
Tera Expert

Hello Team,

 

I am looking for the help to extract RITM number from the below text. Here date & RITM number will may changes as per the created date .


Text is --- "[01-12-2023 RITM#10273187] Company created"



Thanks in advance
Vinay

1 ACCEPTED SOLUTION

Hi @Vinay49 ,

 

Try updated code

 

var a = '[01-12-2023 RITM#10273187] Company created';
a = a.split(']');
var b = a[0].split(' ');
b = b[1];
gs.info(b);

 

DanishBhairag2_0-1701936865686.png

 

 

Thanks,

Danish

 

 

 

View solution in original post

10 REPLIES 10

Hi Dinesh,

 

Thanks for your reply, 
It should display the RITM number with "#".
i.e. RITM#10273187. Then only we can use this & query from RITM table.

can you help on it?

 

Thanks in advance



Hi @Vinay49 ,

 

Try updated code

 

var a = '[01-12-2023 RITM#10273187] Company created';
a = a.split(']');
var b = a[0].split(' ');
b = b[1];
gs.info(b);

 

DanishBhairag2_0-1701936865686.png

 

 

Thanks,

Danish

 

 

 

Shamma Negi
Kilo Sage
Kilo Sage

Try this

 

var a = '[01-12-2023 RITM#10273187] Company created';
a = a.split(']');
var b = a[0].split(' ');
var b_final = b[1].substring(4);
gs.info(b_final);

 

Result :

 

*** Script: #10273187
Regards,Shamma Negi

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Vinay49 ,
I trust you are doing great.
Please find the below code for the same :

var text = '[01-12-2023 RITM#10273187] Company created';
text = text.split(']')[0]; // Splits at ']' and takes the first part
var ritmNumber = text.split(' ')[1]; // Splits at space and takes the second part
gs.info(ritmNumber); // Logs the RITM number including '#'

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Akshata T
Tera Guru

@Vinay49 Use below code for this. You will get the date and RITM separately. 

 

var text = '[01-12-2023 RITM#10273187] Company created';
var splitWithSpace = text.split(' ');
var splitWithBracket = splitWithSpace[0].split('[');
var getDate = splitWithBracket[1];
gs.info("date "+ getDate);
var splitWithHash = splitWithSpace[1].split('#');
var splitWithBracket = splitWithHash[1].split(']');
var getRITM = splitWithHash[0] + splitWithBracket[0];
gs.info("ritm " + getRITM);