Get value from last occurrence of - to begining of string

Hi Team,

I have a situation where i am trying to get the value as

string = XYz-aksjdf-ads77fasd-adsfdf558asdf-asdfasdf-01011

now i want just the = XYz-aksjdf-ads77fasd-adsfdf558asdf-asdfasdf

how do i split i am using the function split but getting only the last number value that is not required.

could somebody please help here

Hi @rahulgola,

Try the following:

YourString.Replace("-" + YourString.Split({"-"},StringSplitOptions.None).Last.Trim,"")

This should remove the last characters you don’t want

Thank you very much @william.coulson :slight_smile:

Cheers,
Rahul

1 Like

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