In above image i will get the input given in the image in string i need to get the number of line in the string
For example based on the given image i need to get the output as 2
hey
can you try the following
yourString.Split({Environment.NewLine}, StringSplitOptions.None).Count.ToString
Regards!
Use as below.
OutStr=InputStr.Split({Environment.NewLine}, StringSplitOptions.None).Count.ToString
where OutStr will give you the count
InoutStr is the Input string
Getting the count as one
plz share the text file which you are trying to count.
Same file which i have shared I cannot share the original file .shared file is a replica of the original one
Hi @sruthesanju
try something like this
-
Read the text file and store in string str1
-
Now use the below code to get the count of lines
System.Text.RegularExpressions.Regex.Matches(str1,β.*β,RegexOptions.Multiline).Count.ToString
Thanks & Regards,
Nived N
check this
regards!
Hi @sruthesanju ,
Could you try with the Below Expression :
Split(yourString,Environment.NewLine).Count
or the below Expression :
System.Text.RegularExpressions.Regex.Split(yourString,"\r\n").Count
Hello @sruthesanju
Mytext.Split(Environment.NewLine.TocharArray).Length
Where Mytext is the input string
Hi @sruthesanju ,
You can try the below code
System.IO.File.ReadAllLines("Your full file path").Length