Get first word from excel

Hi guys

I have this data from excel, “VALENCIA, SPAIN”.
The question is, how to get the data only the first word “VALENCIA”
Ignore the comma and the second word.

Hi @gilang_ramadhan123

You could use the Split method. Be careful if you have leading spaces at the begining of the text, in that case it will be safe to apply Trim methodbefore the substring.

image

Bests,
Andres

Thanks sir ill try

sir i was try, it worked
but i cant use Split(" "), so i use argument like this wholeText.Trim.Split.First
and the result is “VALENCIA,” there is still have a comma, i want to ignore the comma too.
From this “VALENCIA, SPAIN” to “VALENCIA”

Try this

System.Text.RegularExpressions.Regex.Match("VALENCIA, SPAIN","\S+(?=,)").Tostring

image

Or

Split("VALENCIA, SPAIN"," ")(0).Replace(",","")

image

Hope this helps

Regards
Sudharsan

thanks sir

Kindly mark appropriate post as solution @gilang_ramadhan123

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