- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 01:29 AM
Hi Team,
i need to split the below sentence using regex, Please help me out in 2nd line of the code.
i want to include the symbols [,],| as delimiters. please suggest me.
gs.print(items[2])
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:38 AM
hi @Srvs
from your code Assuming urlify function is defined elsewhere
Please try like below
var finComment = 'test [Click Here|http://example.com]';
var htmlComment = finComment;
var sysIdList = htmlComment.match(/^(.*?)\s*\[(.*?)\|(.*?)\]$/);
if (sysIdList) {
var part1 = sysIdList[1];
var part2 = sysIdList[2];
var part3 = sysIdList[3];
var htmlOutput = part1 + '[code]<a href="' + part3 + '" target="_blank">' + part2 + '</a>[/code]';
gs.print(htmlOutput);
} else {
gs.print("No match found");
}
i am getting output as :
test[code]<a href="http://example.com" target="_blank">Click Here</a>[/code]
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 03:04 AM
Hi @Bhavya11
its returning exactly in background script,
im trying to execute the script in flow designer, which will take the input from jira and process for servicenow comments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 04:21 AM
Hi @Bhavya11
i removed the $ symbol from var sysIdList = htmlComment.match(/^(.*?)\s*\[(.*?)\|(.*?)\]$/);
now its working perfect.,
thanks a lot for your help 🙂