id プロパティを持つ dataItems を含むリストを検索し、そのような id のリストに対するヒットを検索する Search クラスを作成しようとしています。
しかし、正規表現を正しく機能させることができません。正規表現を含む文字列変数を印刷してから、変数の代わりにそれと照合してみました。これにより、奇妙な理由で機能します。
私はこの方法でそれを行います:
private <D extends dataItem> boolean subSearch(D d){
boolean b = false;
for(String sf: d.getSearchField(searchF)){
System.out.println(sf); //String of id I match against
System.out.println(searchQ); //Prints "(A0A5E1)|(A4QPC6)|(A6NC42)|(A6NMB1)|(A6NI73)"
System.out.println(sf.matches("(A0A5E1)|(A4QPC6)|(A6NC42)|(A6NMB1)|(A6NI73)"));//Prints true
b = b || sf.matches(searchQ);
if(sf.matches(searchQ)){ //Does not match when sf.matches("(A0A5E1)|(A4QPC6)|(A6NC42)|(A6NMB1)|(A6NI73)") matches
System.out.println(searchQ);
System.out.println(sf);
}
}
return b;
}
sf.matches(searchQ) で何が問題になっているのかについてのアイデアはありますか?