1
2次元配列に保存されたStringのコレクションを持っています。 文字列はホーン節の形をしていて、完全な1つの文字列は、?x = alexを書くならば、患者(?x)の形であり、hasdoctor(?x、?y)正規表現内のすべてのマッチを印刷する正規表現ですか? and、or)
?yは、ジョンは、次いで上記の文字列は
患者の構造(アレックス) hasdoctor(アレックス、ジョン)かかり=
今問題になっていることは?Xを見つけ以下のコードを使用するが、場合でありますhasdoctor(?x、?y)は?yをスキップします。私はJavaで欲しいことを説明することができます
void find_var(String[][] temp)
{
System.out.println(temp.length);
System.out.println(temp[0].length);
for(int i=0;i<temp.length;i++)
for(int j=1;j<temp[0].length-1;j++)
{
String text_to_parse=temp[i][j];
Pattern y = Pattern.compile("[?]\\w[,)]");
Matcher z= y.matcher(text_to_parse);
if(z.find())
{
System.out.println("Found at::"+temp[i][j]);
System.out.println(z.group());
}
else
{
System.out.println("Not found at::"+temp[i][j]);
}
}}
pesudoコードがある
if([?]\\w[,) is found in array[][])
if([?]\\w[,) is already in other_array[]
Then skip;
else
save [?]\\w[,) to other_array[]
うわー、うまく働いた、ありがとう。 –
Cool。あなたは新しいユーザーなので、[this](http://stackoverflow.com/help/someone-answers)を見てください。 –