diff --git a/pom.xml b/pom.xml
index 299cf79..219df0d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.github.ucchyocean
LunaChat
- 3.0.10
+ 3.0.11
A powerfull chat channel plugin with IME (Kana-Kanji conversion) support
https://github.com/ucchyocean/LunaChat
diff --git a/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java b/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java
index 8c6fbca..218be3b 100644
--- a/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java
+++ b/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java
@@ -29,9 +29,10 @@ public class KeywordReplacer {
* @param value 値
*/
public void replace(String keyword, String value) {
- int start;
- while ( (start = str.indexOf(keyword)) > -1 ) {
- str.replace(start, start + keyword.length(), value);
+ int index = 0;
+ while ( (index = str.indexOf(keyword, index)) > -1 ) {
+ str.replace(index, index + keyword.length(), value);
+ index += value.length();
}
}
diff --git a/src/test/java/com/github/ucchyocean/lc3/util/KeywordReplacerTest.java b/src/test/java/com/github/ucchyocean/lc3/util/KeywordReplacerTest.java
index 8a0a9b3..cb75d0e 100644
--- a/src/test/java/com/github/ucchyocean/lc3/util/KeywordReplacerTest.java
+++ b/src/test/java/com/github/ucchyocean/lc3/util/KeywordReplacerTest.java
@@ -42,4 +42,32 @@ public class KeywordReplacerTest extends TestCase {
assertTrue(test1.equals(test2.toString()));
}
+
+ public void testaaa() {
+
+ String testee = "%prefix%username&f: %msg";
+ String keyword = "%msg";
+ String val1 = "&f%japanize&7 #%msg";
+ //String val2 = "発言の内容";
+ String val2 = "%msg発%msg言%msgの%msg内%msg容%msg";
+
+
+ KeywordReplacer test1 = new KeywordReplacer(testee);
+ long start = System.currentTimeMillis();
+ test1.replace(keyword, val1);
+ test1.replace(keyword, val2);
+ long time = System.currentTimeMillis() - start;
+ System.out.println("test1 time = " + time + ", str = " + test1.toString());
+
+
+ String test2 = new String(testee);
+ start = System.currentTimeMillis();
+ test2 = test2.replace(keyword, val1);
+ test2 = test2.replace(keyword, val2);
+ time = System.currentTimeMillis() - start;
+ System.out.println("test2 time = " + time + ", str = " + test2);
+
+
+ assertTrue(test1.toString().equals(test2));
+ }
}