|
|
|
|
39
|
}
|
39
|
}
|
40
|
|
40
|
|
41
|
public String changeWord(String search, String replace){
|
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
|
Matcher m = patt.matcher(hamletData);
|
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
|
int count = 0;
|
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
|
Matcher m = patt.matcher(hamletData);
|
50
|
Matcher m = patt.matcher(hamletData);
|
51
|
while (m.find())
|
51
|
while (m.find())
|
52
|
count++;
|
52
|
count++;
|