I need to keep the first 5 words from returned string, stripping of the balance.
eg. I want to keep “Stackoverflow is an amazing resources” from the word below
Stackoverflow is an amazing resources for developers
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use Substring in combination with IndexOf.
Or you could use Remove:
Or (as answered by paulius_i) Replace:
Edit: You’ve modified your question essentially, so here is a way to get the first n words of a string: