Remove spaces

I have two strings String1 and string2.
Value comes in string1 is New Jersey
Value comes in string2 is New hampshire.
i want a condition where bot to check the length of the words


And if you need to get the length without surrounding spaces:

And if you need to actually trim the data, assign as follows:
String1 = String1.Trim
String2 = String2.Trim

If you’re counting all characters which aren’t spaces:
String1.Replace(" ", String.Empty).Length
String2.Replace(" ", String.Empty).Length


I have condition where i use a website. on the website there is a dropdown field of states but for few states below
New Hampshire
New Jersey
New Mexico
New York
and value entered in this fields is coming from a excel sheet where the BOT type the name of that state in the particular field but due to site functionality it defaults to New hampshire eventhough i an typing New jersey or new mexico
but if i match the length of the state it still counts to 6
please advic eany other condition

Use this below code to get only the words count, @Mufaddal_Burhani
System.Text.RegularExpressions.Regex.Matches(“STFFTFS TBFTSFT”,"[A-Za-z]").Count