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
ppr
(Peter Preuss)
March 8, 2023, 7:39pm
2
@madhabhazra0
Welcome to the forum
we can do with regex and later trim the result:
This CheatSheet introduces the basic use of regex functions. With further examples also special cases are presented.
Introduction
From the namespace System.Text.RegularExpressions following methods are offered:
Regex.Match
Regex.Matches
Regex.isMatch
Regex.Replace
Regex.Split
A simple usage for example would look like this:
[grafik]
Recommendation:
add System.Text.RegularExpressions to the imports:
[grafik]
it allows to use the shortened statement, as the namespace part can be ommited…
postwick:
(?<=])(.*?)(?=[)
Can you please send me the UiPath syntax with Regex?
ppr
(Peter Preuss)
March 8, 2023, 7:50pm
5
strPattern = (?<=\]).*(?<=\[)
Assign Activity
strResult = System.Text.RegularExpressions(YourStringVar, strPattern).Value.Trim
You can also refer to the linked CheatSheet
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
Regards!
Thanks for the help!!
This solution is also worked.
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