|
@@ -39,14 +39,14 @@ public class HamletParser {
|
39
|
39
|
}
|
40
|
40
|
|
41
|
41
|
public String changeWord(String search, String replace){
|
42
|
|
- Pattern patt = Pattern.compile("^" +search + "", Pattern.CASE_INSENSITIVE);
|
|
42
|
+ Pattern patt = Pattern.compile("\\b" +search + "\\b", Pattern.CASE_INSENSITIVE);
|
43
|
43
|
Matcher m = patt.matcher(hamletData);
|
44
|
|
- return m.replaceAll(replace);
|
|
44
|
+ return m.replaceAll("" + replace + "");
|
45
|
45
|
}
|
46
|
46
|
|
47
|
|
- public int findWord(CharSequence hamletData ,String search) {
|
|
47
|
+ public int findWord(String hamletData ,String search) {
|
48
|
48
|
int count = 0;
|
49
|
|
- Pattern patt = Pattern.compile("^" +search + "", Pattern.CASE_INSENSITIVE);
|
|
49
|
+ Pattern patt = Pattern.compile("\\b" +search + "\\b", Pattern.CASE_INSENSITIVE);
|
50
|
50
|
Matcher m = patt.matcher(hamletData);
|
51
|
51
|
while (m.find())
|
52
|
52
|
count++;
|