Trim the string

Hello all.
I’ve a full path “C:\Users*****\Documents\SAP\SAP GUI\”.
How to trim from the above path?

Hi @happyfeat87,

If you wanted the full file name from the full path, you could do the following:

StringVar = FilePath.ToString.Split({"\"},StringSplitOptions.None).Last.Trim
Edit: This above expression gives the output “”, should you need to use the filename for anything.

From there, you could use Regex pattern \d{8}\.\w* to get the part you need:

I take it the last 8 characters are a date format, so I have used {8} for matching the digits

1 Like


Can you try the following expression?




@william.coulson yes. In C:\Users*****\Documents\SAP\SAP GUI\”.

20220511 is dynamic( In date format).

Hi @happyfeat87,

In this case, either mine or @Yoichi’s regex patterns will work for you, trusting the date format will always remain in the same format of 8 numbers.

Edit: @Yoichi’s regex pattern will work better as it will still pick up the item if there is something after “.zip”

1 Like

How to get the string C:\Users*****\Documents\SAP\SAP GUI\RC2AnalysisDataID8 ignoring
Currently I am trying this “C:\Users\Dinesh\Documents\SAP\SAP GUI\RC2AnalysisDataID8”&“yyyyMMdd”)&“.zip”

Hi @happyfeat87,

Try using Regex to get that item out, and then replace it with nothing:

In an assign:
RegexItem =

In a seperate assign:
Filepath = Filepath.Replace(RegexItem,"")

If RegexItem is “”, then replacing it with nothing should give you the expected filepath.

Edit: Though, if you already have the filepath, you won’t need to manipulate it? You’re already referring to it:

Just assign everything before the first & to a variable.

1 Like

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