Hello, suppose I have a string that has length n.
Now if m<n is given, I want to find all substrings which have a fix length m.
Is there a quick way?
Thanks for share your code.
Printable View
Hello, suppose I have a string that has length n.
Now if m<n is given, I want to find all substrings which have a fix length m.
Is there a quick way?
Thanks for share your code.
Not unless there is a distinct delimiter between each sub-string
Code:// set m 'n' n
int n = 20;
int m = 7;
// make a "reasonable" test string of length n
string myString = string.Empty;
for (int i = 0; i < n; i++)
myString += (i % 10).ToString();
// show all substrings of length m
for (int i = 0; i < n - m + 1; i++)
Debug.WriteLine(myString.Substring(i,m));
scarf
scar
car
scarf