Process Str
Process only ()
While (bg>-1) {// get the next "(" and ")" position BG = Str. indexof ("(", Ed); ED = Str. indexof (")", BG + 1); // if there is no next "(", it will jump out of the loop if (BG =-1) break; // "\ r \ n" is used to wrap substr + = Str. substring (bg + 1, Ed-BG-1) + "\ r \ n ";}
For STR processing containing [()]
While (bg>-1) {// get the next "[" and "]" position BG = Str. indexof ("[", Ed); ED = Str. indexof ("]", BG + 1); // if there is no next "[", it will jump out of the loop if (BG =-1) break; // obtain the content in "[]". The position of "(" and ")" is initially 0 substr = Str. substring (bg + 1, Ed-BG-1); subbg = 0; subed = 0; // search for the next "(" and ")", until no "(" jumps out of the loop while (subbg>-1) {// gets the position subbg = substr of the next. indexof ("(", subed); subed = substr. indexof (")", subbg + 1); // if the next pair cannot be found, the IF (subbg =-1) break will pop out; // Add the new string rtstrtemp + = substr after the returned string. substring (subbg + 1, subed-subbg-1); // a line of string rtstr + = rtstrtemp + "\ r \ n" \ add after each line of string line break }}