Remove last 6 characters of a string

Hey,

Have a problem with removing the last 6 characters of a string.
I have a get text activety that gets name and number however I wanna remove the number:

Name:
Tommy Lundgren 123654
John Stockton 123666
Ella Abba 144456

I’ve tried the guid for How to manipulate a part of string: Split, Trim, Substring, Replace, Remove, Left, Right - #36 by Adrian_Star

Can someone please give me some advice?

@TOOKT

Assign
Var=System.text.regularexpression.regex.match(input,“[A-Za-z\s]+”).value

Try this

Cheers

Hi @TOOKT

Use the below regular expression

- Assign -> StrVar = "Tommy Lundgren 123654
                      John Stockton 123666
                      Ella Abba 144456"
- Assing -> Output = System.Text.RegularExpressions.Regex.Replace(StrVar.ToString,"(\d{6})","").trim

Check the below workflow for better understanding

Hope it helps!!

2 Likes

Use this regex pattern
take assign activity and
give some variable and in value to save
System.Text.RegularExpressions.Regex.Match(input String variable,“.*(?=\d{6})”).Value

Hope this helps

1 Like

Hi @TOOKT

NamewithNumber.Substring(0, NamewithNumber.Length - 6)

Belive it or not but ChatGPT solved it with, I’m sure all your suggestions will work tho.

System.Text.RegularExpressions.Regex.Replace(“strName”, “.{6}$”, “”)

1 Like

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