Hi
I have a textbox which contains Text.
I want to find all the words in the text. (which seprate from each other with space).
what should I do?
thx for ur attention.
Dajer 0 Junior Poster in Training
Recommended Answers
Jump to PostIf you know your string contains only words separated by spaces you could use:
string Mystr = "This is a sentence."; string[] split = Mystr.Split(new Char[] {' '});
Now split[1] would contain the word "is".
Jump to Post>>I want to find all the words in the text. (which seprate from each other with space).
You changed the rulesBut to answer your question you can use RegEx:
private void button15_Click(object sender, EventArgs e) { const string sentence = @"This is Daniweb Forums.Good Luck"; …
Jump to PostAlthough regex would be the way to go here, I just want to point out that this would also work:
Mystr=@"This is Daniweb Forums.Good Luck" ; string[] split = Mystr.Split(new Char[] {' ','.'});
All 12 Replies
DdoubleD 315 Posting Shark
ddanbe 2,724 Professional Procrastinator Featured Poster
DdoubleD 315 Posting Shark
Dajer 0 Junior Poster in Training
sknake 1,622 Senior Poster Featured Poster
DdoubleD commented: this guy knows everything! +1
DdoubleD 315 Posting Shark
sknake 1,622 Senior Poster Featured Poster
Dajer 0 Junior Poster in Training
sknake 1,622 Senior Poster Featured Poster
Dajer 0 Junior Poster in Training
sknake 1,622 Senior Poster Featured Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
DdoubleD commented: good follow up +1
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.