<summary>///get the longest string of digits///</summary>///<param name= "inputstr" > Input string </param>///<ret urns> Maximum number </returns> public string Getmaxlennumber (string inputstr) {//storing characters in a string in an array for easy processing char[] Strchararra
y = Inputstr.tochararray ();
position to begin processing int startpos = 0;
The character length of the current processing int tempcharcount = 0;
The longest length of the number int maxlen = 0;
Total length of array int len = strchararray.length;
int pos = 0;
while (Startpos < len) {//the temporary maximum length int tempmax = 0 in the loop;
while (Tempcharcount + startpos < len) {//start processing char c = strchararray[tempcharcount + startpos]; if (char.
Isnumber (c)) {//If it is a digital tempmax++;
if (Tempmax > MaxLen) {maxlen = Tempmax;
pos = startpos;
} else {//not number Tempmax = 0;
startpos++;
Break
} tempcharcount++;
} if (startpos + tempcharcount = len) { Break
} tempcharcount = 0;
string s = inputstr.substring (pos, maxlen);
return s; }
The above is the entire content of this article, I hope to give you a reference, but also hope that we support the cloud-dwelling community.