Removing brackets [] inside a string

I have the following string:
“- [RPUIN-01/31/2023 12:38:32 PM] Contact ABC TEST - [ TEST UIPOMIN-01/31/2023 12:38:52 PM]”

I only want to have the part outside the brackets:
“Contact ABC TEST”

I’m not able to remove the brackets…

Thank you for the help

@madhabhazra0
Welcome to the forum

we can do with regex and later trim the result:

1 Like

Use regex:

(?<=\])(.*?)(?=\[)

Then trim it

Can you please send me the UiPath syntax with Regex?

strPattern = (?<=\]).*(?<=\[)

Assign Activity
strResult = System.Text.RegularExpressions(YourStringVar, strPattern).Value.Trim

You can also refer to the linked CheatSheet

1 Like

Thanks for your help !!

sDescription = “- [SADMIN-01/31/2023 12:38:32 PM] Contact ABC TEST - [ TEST SADMIN-01/31/2023 12:38:52 PM]”
sPattern = (?<=]).*(?<=[)

Please find the attached syntax that worked for me.
sResult = System.Text.RegularExpressions.Regex.Match(sDescription, sPattern).Value.Trim

Hi @madhabhazra0

Give a try with

System.Text.RegularExpressions.Regex.Match(strInput, "(?<=\]\s)(.*?)(?=\s-\s\[)").Value.Trim

image

Regards!

1 Like

Thanks for the help!!

This solution is also worked.

1 Like

Hi I have one Input String.
I want to delete everything inside the bracket.

Example -
Input String - John Smith - [ADMIN-01/31/2023 12:38:32 PM] and second and [third] - [ M] also - [ADMIN-01/31/2023 12:38:52 PM] and 4th - [TEST-02/21/2023 abc 01:37:23 AM]

Output - John Smith and second and also and 4th

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