I have a sentence where I need to get the number words in that sentence how could I achieve this.
StrOut=InputStr.count.ToString
@soumi_soumiya
Split the string using yourstring.Split({" "}, StringSplitOptions.None) this will give you Array of string then use ArrayVar.count this will give you number of words present in the sentence.
Regards
@soumi_soumiya Split the sentence with respect to space and use count method on it, then you will get number of words in that sentence.
Ex: Str = “How are you”
int WordCount = Str.Split({" "},StringSplitOptions.RemoveEmptyEntries).Count
split based on the space and get the count of the array.
count = InputString.Split("").Count
Regards
Ajay
Hi @soumi_soumiya,
Int var= yourString.split(" "C).count
Thanks!
Thanks for your reply…
I have done but it gives me only the number of letter in the sentence not the number of words
Try this.
count = InputString.Split(" "c).Count.ToString
“place your sentence here”.count.ToString
split the string and then use count function on the array.
Thanks for your reply…
I have an other concern is that i have a paragraph where i need to know how many lines are there how could i achieve it
StrOut=InputStr.Split({Environment.NewLine}, StringSplitOptions.None).Count.ToString
for Paragraph you need to split the string based on the Environment.newline
Hi,
It is a different approach using the regex.
intCount= Regex.Matches(strString, “\S+”).Count

test.xaml (4.8 KB)
output

Regrads
Balamurugan.S
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
