我想在一定長度後分割一個字符串。如何在一定長度之後使用拆分字符串?
比方說,我們有「消息」
Who Framed Roger Rabbit
斯普利特這樣的字符串:
"Who Framed" " Roger Rab" "bit"
而且我想分裂時,「消息」變量超過10
我目前的分割代碼:
private void sendMessage(String message){
// some other code ..
String dtype = "D";
int length = message.length();
String[] result = message.split("(?>10)");
for (int x=0; x < result.length; x++)
{
System.out.println(dtype + "-" + length + "-" + result[x]); // this will also display the strd string
}
// some other code ..
}
你目前獲得的輸出是什麼? –
你想分開什麼第11個字符?如果消息是'abcdefghijklmnop',應該是OP嗎? – TheLostMind
看看[N-gram從一個句子生成](http://stackoverflow.com/questions/3656762/n-gram-generation-from-a-sentence) – aioobe