JS segmentation:
VaR S = 'I am 1234567890 I am 1234567890 I am 1234567890 I am 1234567890 I am 1234567890 ',
Reg =/. {4}/g,
Rs = S. Match (REG );
Rs. Push (S. substring (Rs. Join (''). Length ));
Alert (RS)
Java segmentation:
Public static string [] Split (string MSG, int num ){
Num = num + 1;
Int Len = MSG. Length ();
If (LEN <= num)
Return New String [] {MSG };
Int COUNT = Len/(Num-1 );
Count + = Len> (Num-1) * count? 1: 0; // It should be worth noting
String [] result = new string [count];
Int Pos = 0;
Int splitlen = num-1;
For (INT I = 0; I <count; I ++ ){
If (I = count-1)
Splitlen = len-Pos;
Result [I] = msg. substring (Pos, POS + splitlen );
Pos + = splitlen;
}
Return result;
}
JS flip:
VaR teststring = "1234567 in love with 8 .. ";
VaR teststring = teststring. Split (""). Reverse (). Join ("");
Java flip
Public void convertstr (string Str ){
// Set string
The object is converted to a variable stringbuffer class object.
// Call the reverse () method of the stringbuffer class to implement inversion.
String strreverse = new
Stringbuffer (STR). Reverse (). tostring ();
System. Out. println (strreverse );
}