How to separate words and digits from a read text file

I have a text file in the given format:
adgjqrw34324
sgk3434
sgkhk872985

Now I need to fetch the words and Digits separate and paste it in excel file. How to achieve this in Uipath?

I have used Read text file and store everything in String. After that I tried to convert string into array but i am getting my array variable called myArray(0), in 0 the whole value. I want to get the values line by line and then separate it. Please help me to achieve it.

once you got the string then split that string with new line and then you will get array …so loop that array and then for to separate the data use regex.

Hi
if this is the string input
–use BUILD DATATABLE ACTIVITY and create a table structure with two columns and get the output withh a variable of type datatable named finaldt
–followed by that use CLEAR DATATABLE ACTIVITY andd mention the datatable as finaldt
–use READ TEXT FILE activity and get the output with a string variable named str_input
–now use a assign activity like this
arr_string = Split(str_input,Environment.NewLine.ToArray())
where arr_string is a variable of type array of string

–now use a FOR EACH activity and pass the arr_string as input and change the type argument as string in the property panel of for each loop
–inside this use assign activity and mention like thiis
str_word = System.Text.RegularExpressions.Regex.Match(str_input,“[a-z]+”)
str_num = System.Text.RegularExpressions.Regex.Match(str_input,“[\d]+”)

now use ADD DATAROW activity and mention in arrayrow propertyy as
{str_word,str_num} and in datatable mention as finaldt

Cheers @Pranav_Kashyap

2 Likes

Thanks for your quick reply but can I know which datatype I need to use for storing str_word = System.Text.RegularExpressions.Regex.Matches(str_input,“[a-z]+”)

1 Like

aah sorry buddy
i forgot to change that expression
just a small change
str_word = System.Text.RegularExpressions.Regex.Match(str_input,“[a-z]+”)
str_num = System.Text.RegularExpressions.Regex.Match(str_input,“[\d]+”)

and both str_word and str_num is of type string
you were almost done
kindly try this and let know for any queries or clarification
Cheers @Pranav_Kashyap

It is showing error when I am using String but when I changed the variable type to **System.Text.RegularExpressions.Regex.Matchecollection" it is working fine. Do I need to change?

After I changed it is working fine… Thank you for your Quick help:)

were the expression changed as mentioned here
it was previously matches but now changed to match

Cheers @Pranav_Kashyap

It is not working Palani…

may i know what was the issue you were facing
Cheers @Pranav_Kashyap

Cannot assign **System.Text.RegularExpressions.Regex.Match" to system.string in assign activity

kindly share the workflow if possible so that i can have a view on it
Cheers @Pranav_Kashyap

It works when we add tpstring **System.Text.RegularExpressions.Regex.Match(str_input,“[a-z]+”).tostring…Thank you

2 Likes

Fine
cheers @Pranav_Kashyap

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