I have a text file with so many lines. From the entire text file I need to extract all the repeated strings in the file after specific string. Let’s say Input is a text file with so much content
Animal.Name=“Forest Elephant_1” <Has it’s own power.>
Output should be:
African Bush Elephant
Need help in doing this. Thanks in advance.
Please attach some sample input txt file.
sampleText.txt (862 Bytes)
Attaching image too.Again it is a sample file with few lines.
@Gokul001 Thanks.Will look into it.
It is working for you
If not, let me know
Split String.zip (41.6 KB)
@Gokul001 It is throwing an error saying “End of Expression Expected”. I passed the expression into pattern property “Matches activity”. Provided input variable and output variable. I am very new to regular expressions concept. Correct me if I did wrong.
@Mr.H Thank you will check it.
Create Variable Rg1 = System.Text.RegularExpression.Regex.Matches(“Input_Variable”, “(?<=Animal.Name=”)(\S.+)(?=_)").Tostring
Can you please share the screenshot of workflow?
There is small mistakes in your method of writing that code, actually Matches returns collection not a single value, so code to be used is
data = System.Text.RegularExpressions.Regex.Matches(input_string,“(?<=Animal.Name=.).*(?=_\d+)”).Cast(Of Match).Select(Function(m) m.Value.ToString).ToArray()
@Kavya_Mamidishetti2 check this
here data is collection of values from regex pattern [DataType : String], input_string is the input text from which u need to extract the data
Hope this helps you
here it is Rg1 is of string type.
@Kavya_Mamidishetti2 - Is this your expected result?
Read Text file and save the output has
Regex pattern …Since there is already a double quote in the string…i have escaped with another so it wont error…
If want to store the results in an Array…then use the below code…
ArrItems = IEnRegEx.Select(function(x) x.ToString).toarray
Hope this helps…
@NIVED_NAMBIAR Hey it worked. Thanks a lot but I didn’t understand the functionality behind the code. The code seems to be a bit advanced to me. Can you suggest any links to understand how functions work?
@Mr.H Yeah. It worked. Thank you so much for the file.
@prasath17 Yes prasanth. That’s the expected result. It is working. Thanks a lot.
You can imagine that code functionality to the Matches activity in uipath,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.