Regex - how can I eliminate spaces and get the words?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Why when I write this

Regex r = new Regex(@"[\s]+")
String [] tokenList = r.Split(line)

If line which is a string, has spaces at the end or start, Regex leaves an empty string at the end and start of the tokenList array?
 
Just to add that I know that I can solve this by using a Trim on “line†before the Regex. I just want to understand the logic of Regex. I should be able to do it all with Regex.
 
Back
Top