Remove Alphabets from the end in Workbook

There are certain numbers in a row where there are alphabets after numbers in a row and columns. I need to remove the characters or alphabets after the numbers in Workbook using UiPath

Hi @ayushi_jain3 ,

Could you provide us with some sample data to check it out, if provided also the Expected Output from it, it would further be helpful to accelerate the reach of Solution.

Hi @ayushi_jain3

By using regex you can get the output

image

Hey, thanks for the quick response. Could you please provide the value set for assign and in the configure regular expression so that I can try it from my end. Thanks in advance !

Hey, Below are the input and output:
Input :slight_smile:

Output:

Hi, set this value for assign.
System.Text.RegularExpressions.Regex.Match(row(“Column1”).ToString, “\d+”).Value

@ayushi_jain3 ,

Maybe we could use the below Regex Expression :

(.*\d+)(.*)

The implementation assuming that you are reading the Excel sheet as Datatable, we can perform the following :
image

The Assign Statements are below :

CurrentRow("Company ID") = Regex.Match(CurrentRow("Master Tax").ToString,"(.*\d+)(.*)").Groups(2).Value.ToString
CurrentRow("Master Tax") = Regex.Match(CurrentRow("Master Tax").ToString,"(.*\d+)(.*)").Groups(1).Value.ToString

image

After the Operation, we could use Write Range activity to Write the Updated Data back to the Excel sheet.

Hi @supermanPunch -

There’s and error in First assign activity as below:

Hi,

If you will get such error then the namespace is not defined, so you can import that namespace.

Hello All,

I used other solution and it worked for me, so just wanted to share:

  1. Read range: output: dt1
  2. Invoke code activity: Use below code

Dim dt1 As DataTable = in_dt1
For Each row As DataRow In dt1.Rows
row(“Column_Name”) = System.Text.RegularExpressions.Regex.Replace(row(“Column_Name”).ToString(), “[a-zA-Z]+$”, “”)
Next row

  1. Write range

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