An extended SPLIT method can separate characters according to string, return character arrays

xiaoxiao2021-03-06  62

/ * Is a small stuff is doing a news release, which is made to the article, that is, according to the separator identifier, returns the number of characters, but the string.split method in the C # can only be separated according to the character or character array, but This cannot be separated according to string, so this method is written. Author: blue.dream statement: To reference this article, keep the original information. * / ////

// / According to the specified tag, the string is separated, and return the number of characters /// /// To separate characters /// Splitted marker /// private string [] splitpage (string source, string split) {int Len = split.length; arraylist Al = new arraylist (); int start = 0; // Start position int J = -1; // match index position while (true) {j = source.indexof (split, start); if (j> -1) {Al.Add (Source.Substring (START, J-START)); int s = j-start; start = j g;} else {al.add (source.substring (start); Break;}} string [] result; if (al.count == 0) {string [] r = new string [1]; r [0] = source; result = r;} else {string [] r = new string [al.count ]; For (int i = 0; i
转载请注明原文地址:https://www.9cbs.com/read-110895.html

New Post(0)