String Trim

Hello guys i have an excel with data containing
image

I want to remove only "-A " or “-B” in the last and should remove for any alphabet letter.

note this string length is not constant it may vary

Hi @Gokul_Murali

How about this Regular expression?

System.Text.RegularExpressions.Regex.Replace(YourString,"-\w$","").Tostring

Use this code in Invoke code activity

dt.AsEnumerable.ToList.ForEach(Sub(x) x("ColumnName") = system.Text.RegularExpressions.Regex.Replace(x("ColumnName").ToString,"-\w$","").ToString.trim)

image

Regard
Gokul

@Gokul_Murali

Please try this in invoke code after reading data into datatable dt and add a argument to invoke code dt with direction as in/out

dt.AsEnumerable.ToList.ForEach(sub(x) x("ColumNname") = System.Text.RegularExpressions.Regex.Match(x,".*(?=-[A-Z])").Value)

image

cheers

Hi @Gokul_Murali ,

Use the invoke code activity and keep dt as in/out argument:

dt.AsEnumerable.ToList.ForEach(Sub(x) x("ColumnName") = system.Text.RegularExpressions.Regex.Replace(x("ColumnName").ToString,"-\w$","").trim)

Regards,

@Gokul001 @vishal.kp

MicrosoftTeams-image (25)

Iam getting error like this.

@Anil_G

Iam getting error like this

Hi @Gokul_Murali ,

Can you share the workflow, to take a closer look?

Regards,

@Gokul_Murali

A small change which I missed, i gave only x inside match it should be x("YourColumname").ToString

dt.AsEnumerable.ToList.ForEach(sub(x) x("ColumNname") = System.Text.RegularExpressions.Regex.Match(x("ColumnName").ToString,".*(?=-[A-Z])").Value)

Hope this helps

Cheers

Hi @Gokul_Murali

I don’t receive any error

Can you try to update the system package and check it

Regards
Gokul

@Gokul001
Test.zip (9.5 KB)

please check the file that i have attached

@Anil_G

BlankProcess9.zip (9.5 KB)

Showing the same error

Hi @Gokul_Murali ,

In this workflow, you are passing a wrong variable as argument inside the Invoke Code activity.

I believe it should be dt and not data1.

@supermanPunch @Gokul001

Thankyou so much

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