Remove Before and After space and find last Value

I have string value and i want extract last value from the string text.
Screenshot 2022-05-09 182021.
I want only barrel com.,cylinder this value wil always dynamic.

1 Like

can you paste this text here

Hi ,
You can use spit and replace functions as shown below

Split(“1 12100-ZW6-000 Barrel comp., cylinder”," “).Last.Replace(” “,”")

Assuming there are more than 1 space between each values


try this
system.Text.RegularExpressions.Regex.Match(txt, "[^\s]+[\s]+[^\s]+[\s]+(.*?$)").Groups(1).Value

where txt = string value

we can apply the Regex.Split Strategy

strLast = Regex.Split(strText, "\s{5,}").Last()

5 is a threshold and you can modify

Are those spaces or tabs in the data?

1 Like

Hey @postwick

I guess that is tab space !


If they’re tabs then split on tab.