Hi,
I have multiple regular expressions in one text file and i need to match each and every regular expression to other text file and extract the data how can i do this can any one help me in this
thanks in advance
Hi,
I have multiple regular expressions in one text file and i need to match each and every regular expression to other text file and extract the data how can i do this can any one help me in this
thanks in advance
Hi @vinathkumar,
i am not sure in what format you have in the text file.
if you have each regular expressions in line by line, you can read the data using Read text file activity, then split using Environment.Newline → loop through if apply the regular expressions to get the data from the other string (get the data using Read Text File activity)
If suppose some other format you need to split based on that.
Regards,
Arivu
Hi arivu,
I have regular expression in the following way,
“Forn 1040 (([0-9]{4}))”
“Farm 1040 (([0-9]{4}))”
“Form 1040 (([0-9]{4}))”
Hi @vinathkumar,
Then follow the same step as i said.
in loop you need to split the string “Forn 1040 (([0-9]{4}))” to “(([0-9]{4}))”.
Regards,
Arivu
Hi @arivu96,
I am unable to loop through the text file data, Would you please help me.
Thanks,
Vinath.
Hi @vinathkumar,
Create string array variable arrayvariable
Assign → arrayvariable = yourText.Split(Environment. NewLine.ToArray)
Loop through the arrayvariable
Regards,
Arivu
As you said multiple regular expression will be there in one notepad and need to apply that expression into another text file.
But with out Loop how you ll execute all the regular expression???
If it is a single expression you can directly apply
Regards,
Arivu
Hi @arivu96,
Can you please send the sample xaml file to loop the regular expression.
Thanks,
Vinath.
Hi @vinathkumar,
1.Read the Text File using Read Text File Activity and store it in strExpression(string variable)
2.Read the another Text File using Read Text File Activity and store it in strText(string variable)
3.create arrvar(String variable)
4.using Assign Activity arrvar=strExpression.Split(Environment.NewLine.ToArray)
5. using For Each activity loop through it.
6. Inside for each body assign the Regular Expression and get the value from the strText
For reference
https://activities.uipath.com/docs/string-is-match
https://activities.uipath.com/docs/string-matches
Regards,
Arivu
Hi @arivu96,
I am unable to write the out put to a text file i am attaching my work flow please check it.Regex.zip (40.7 KB)
Hi @vinathkumar,
“Forn 1040 (([0-9]{4}))”
“Farm 1040 (([0-9]{4}))”
“Form 1040 (([0-9]{4}))”
This is the correct format
(Form 1040 ([0-9]{4}))
(Farm 1040 ([0-9]{4}))
(Form 1040 ([0-9]{4}))
can you check regarding this.
And Also Matches activity stored in Variable1
After Matches in the for loop you need to store the result in some variable
Regards,
Arivu
I have moved this post into the #rpa-dev:rookies category as it is not a question about Orchestrator. Also, please ask questions only once. I responded to the same question in a different thread yesterday:
Hi @arivu96,
After making changes as per the above you mentioned also i am unable to write the out put into the text file
Thanks
Vinath
Hi @vinathkumar,
format changed while paste , Please use above one.
(Form 1040 \([0-9]{4}\))
(Farm 1040 \([0-9]{4}\))
(Form 1040 \([0-9]{4}\))
Read Regex Text file store it into ->strRegex
Read Input Text file store it into ->strInput
create string ->arrvalue
arrvalue= strRegex.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)
create IEnum (variable type IEnumerable)
For loop arrvalue
use Matches activity pass input->strInput and Pattern->item and output->IEnum
use another foreach IEnum to get all the matching data store it into list/Stringbuilder
Finally store the output into Text file.
Regards,
Arivu
HI @vinathkumar,
Please refer this xaml File.
Main.xaml (11.2 KB)
Regex text file
(Form 1040 \([0-9]{4}\))
(Farm 1040 \([0-9]{4}\))
(Form 1040 \([0-9]{4}\))
Regards,
Arivu
Hi @arivu96,
I have another query can you please help on this
How to search a specific word in a text file and display a word with corresponding line number.
Thanks,
Vinath.
Hi @vinathkumar,
I have one idea.
using Read Text File read the text and store it in string variable.
using Environment.NewLine split the string to list.
check the string is available in the list using contains function and get the index also.
The Index is the line number of the text in the text file.
Regards,
Arivu