How to get last n characters from a row value to other column

HI Team,

I need to get the last n characters till space from a column and paste that in to a new column .

Input:

Name Special
KK JJ PPP
NN II KKKK

Output:

Name Special
KK JJ PPP
NN II KKKK

@karthik_kulkarni1

try this

  1. add new column using add data column
  2. then use invoke code with with dt as in/out type dt.AsEnumerable.ToList.ForEach(sub(r) r("NewColumn") = r("OldColumn").ToString.Trim.Split({" "},StringSplitOptions.None).Last)

cheers

1 Like

Hi,

Can you try the following sample?

CurrentRow("Special")=CurrentRow("Name").ToString.Split({" "c}).Last()
CurrentRow("Name")=System.Text.RegularExpressions.Regex.Replace(CurrentRow("Name").ToString,"\s+\S+$","")

Sample20231003-1L.zip (3.1 KB)

Regards,

One of many options

For each Row in DataTable Activity | row in dtData

  • Assign Activity: myMatch | DataType: Match =
System.Text.RegularExpressions.Regex.Match(row("Name").toString.Trim,"(.*)(\ .*)")
  • Assign Activity: row("Name") = myMatch.Groups(1).Value.Trim
  • Assign Activity: row("Special") = myMatch.Groups(2).Value.Trim

Hi,

If you are using StudioX. the following will work

NewBlankTask20231003-2.zip (54.6 KB)

Regards,

Thanks its working from your code

1 Like

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