- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:28 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 12:14 AM
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);
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:41 PM - edited 12-06-2023 11:44 PM
Hi @Vinay49 ,
Try this script:
function extractRITMNumber(text) {
var ritmPattern = /RITM#\d+/g;
var ritmMatch = text.match(ritmPattern);
if (ritmMatch) {
var ritmNumber = ritmMatch[0].replace('RITM#', '');
return ritmNumber;
} else {
return 'No RITM number found in the text.';
}
}
var text = "[01-12-2023 RITM#10273187] Company created";
gs.log("RITM"+extractRITMNumber(text)); // Outputs: 10273187
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:54 AM
@Vinay49 ,
Can you try this:
function extractRITMNumber(text) {
var ritmPattern = /RITM#\d+/g;
var ritmMatch = text.match(ritmPattern);
if (ritmMatch) {
//var ritmNumber = ritmMatch[0].replace('RITM#', '');
return ritmMatch;
} else {
return 'No RITM number found in the text.';
}
}
var text = "[01-12-2023 RITM#10273187] Company created";
gs.log(extractRITMNumber(text)); // Outputs: RITM#10273187
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 08:41 PM
Hi @Vinay49 ,
Is your query resolved?
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:42 PM
Hi @Vinay49 ,
U can try below code.
var a = '[01-12-2023 RITM#10273187] Company created';
a = a.split(']');
var b = a[0].split(' ');
b = b[1].replace(/[^a-zA-Z0-9]/g, '');
gs.info(b);
Thanks,
Danish