Regex to fetch specific items from string

Hi Team,

I have list of available options separated by ‘|’ character. Few of the options can be of ‘Shared list’ type. I need to fetch only those matches among the options which contains the keyword ‘Shared list:’

Input String -

ABC|DEF|Shared list : Brand_Name|GHK|Shared list : Brand_Type|MNO|PQR|

Output String1 - Shared list : Brand_Name
Output String2 - Shared list : Brand_Type

Hi @DewanjeeS - Please try like this…

1 Like

@prasath17 … Thanks a ton as always :slight_smile: Really appreciate the quick response and it is giving me the exact result I was looking for.

1 Like

@prasath17 … I have a general query related to Regex activities.
Say, I am using one Regex to replace certain tags with certain characters.
Now in-case there is no match for any of the tags which I planned to replace, will it throw any error? or, it will just check for that tag and since there is no such entry in that file it will simply skip it and proceed with the next activity?
My understanding , it should not throw any error even if tags does not exists - Can you please confirm the same though?

@DewanjeeS - if you are using regex.replace it will not throw an error I guess (You can give it a try)

Or If you are first getting the match and then using string.replace , in this case what you can do is look for the count if the count is >= 1 then it mean there is some elements matches…if matched then you can do your replace activity…

Hope this helps…

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.