Javaで部分一致する方法をいつも忘れてしまうのでメモっとく。
文字列str1に文字列str2が含まれていればtrue。
.java
public boolean isMatch(String str1, String str2) {
if(str1.matches(".*" + str2 + ".*")) {
return true;
}
else {
return false;
}
}
Go to list of users who liked
More than 5 years have passed since last update.
Javaで部分一致する方法をいつも忘れてしまうのでメモっとく。
文字列str1に文字列str2が含まれていればtrue。
public boolean isMatch(String str1, String str2) {
if(str1.matches(".*" + str2 + ".*")) {
return true;
}
else {
return false;
}
}
Register as a new user and use Qiita more conveniently
Go to list of users who liked