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

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?
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

simple regex question? 2
Regex help 2
Newbie question about Regex 8
Var type 4
Rookie thoughts on Regex--useful but not complete 28
regex help 1
How to get rid of the regex???? 6
Regex - Matching URLS 2

Top