Input : this is test=“[sample]” string with=“[some]” special words. “[another one]”
Expected out :
test
with
Pattern :
=[“Word”]
Input : this is test=“[sample]” string with=“[some]” special words. “[another one]”
Expected out :
test
with
Pattern :
=[“Word”]
@Hari I hope, This will solve your problem, you need to learn the regex pattern then you are able to write the custom regex
UiPath Analysis
While UiPath doesn’t have built-in regex functionalities, you can leverage its regular expression activities within workflows for text manipulation tasks. Here’s a general approach:
Import the System.Text.RegularExpressions Namespace:
Import Namespace
activity to include System.Text.RegularExpressions
. This grants access to regex classes.Create a Regular Expression Pattern:
=\[([^\]]*)\]
). Here’s a breakdown:
=
: Matches a literal equal sign.\[
: Matches a literal square bracket.(
: Starts a capturing group.[^\]]*
: Matches zero or more characters that are not square brackets ([]
). This captures the word before the brackets.)
: Ends the capturing group.\]
: Matches a literal closing square bracket.Use the Matches
Activity:
Matches
activity to find all occurrences of the pattern in your input string. Provide the input string and the regex pattern as arguments.Access Captured Groups:
Matches
activity outputs a collection of Match
objects. To extract the captured word, use the Groups
property of a Match
object and access group 1 (index 0).Tutorial Mode
1. Sample Input String:
"this is test=[sample] string with=[some] special words. [another one]"
2. UiPath Workflow:
Create a new UiPath workflow.
Drag and drop the following activities:
Assign
(2 instances)Matches
Variable Setup (Assign Activity 1):
inputString
(to hold the sample input)pattern
(to store the regex pattern)inputString
.=\[([^\]]*)\]
to pattern
.Matching Words (Matches Activity):
Input
property to inputString
.Pattern
property to pattern
.Match
objects in a variable named matches
.Extracting Words (Assign Activity 2):
matches
collection.
Assign
activity:
To
property to a new string variable (e.g., extractedWord
).Value
property, use the expression matches.Current.Groups(1).Value
. This extracts the captured word (group 1) from the current Match
object.Write Line
activity within the loop.Expected Output:
test
with
Explanation:
Matches
activity finds all occurrences of the regex pattern in the input string.Match
object.matches.Current.Groups(1).Value
.Additional Considerations:
hi @Hari i hope this is what you’re looking for.
(?<=[a-zA-Z]+=“[)[a-zA-Z]+(?=]”)
(?<=[a-zA-Z]+=“[) = starts with sth. like xxx=”[ or aA="[ etc.
[a-zA-Z]+ = at least one letter
(?=]“) = ends with ]”
cheers
@Hari is your issue solved?
Thanks for the information , with some modification it worked. Cheers!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.