Finding a match using regex

Hallo,

I need to Open a Text File in Notepad++ and then find a numerical value in the file using regex in format “\d{4}.\d{4}”.
The activity “Matches” only allows the Input as string all I have is a file name.
Is there a way where i can simply open the file without copying all its content in a string and find a match in the file.

Hi @parnalmahavir.patni

1.Read Text File activity

2.match = System.Text.RegularExpressions.Regex.Match(fileContent, “\d{4}.\d{4}”).Value

Regards,

@parnalmahavir.patni

image

Regards,

Hi @parnalmahavir.patni

It is not a good Practice to open the Notepad++ file and search for the data by using UI activities. Instead of that read the text file by using Read Text file activity it will not take much time to read the file and use the Regular expressions to extract the required data.

Hope you understand!!

1 Like

If I give the fillename UiPath cant find it as it is in Network directory.
I get the error “Could not find file” the reason being it tries to find the file in my Project directory and I cant move this file from there.
If I give the right path of where my file is located i do not get any matches. Also, I couldnt tell if the file was opened.

It also returns values like 1234\1234 instead of 1234.1234

@parnalmahavir.patni

\d{4}\.\d{4}

image

Regards,

1 Like

This works. Thanks a lot

1 Like

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