Skip to content

令和元年度 秋期 ITパスポート試験 問99

This question's explanation and your answers so far.

問99
頻出度★★☆

ワイルドカードに関する次の記述中の a,b に入れる字句の適切な組合せはどれか。 任意の1文字を表す“?”と,長さゼロ以上の任意の文字列を表す“*”を使った文字列の検索について考える。[ a ] では,“データ”を含む全ての文字列が該当する。また,[ b ] では,“データ”で終わる全ての文字列が該当する。

出典 令和元年度 秋期 ITパスポート試験 問99
解説

問 99

  • Incorrectア

    In a, “?data*” requires exactly one character for “?”, so “data” alone and strings beginning with “data” do not match, failing to satisfy “contains”. In b, “?data” likewise fails: “data” alone and words with two or more characters in front do not match, so it does not satisfy “ends with”.

  • Incorrectイ

    Although b's “*data” is correct, a is “?data*”, and “?” forces exactly one character immediately in front, so “data” alone and strings beginning with “data” are missed, and it cannot express “all strings containing data”.

  • Incorrectウ

    Although a's “*data*” is correct, b is “?data”, and “?” forces exactly one character immediately in front, so “data” alone and words with two or more characters in front do not match, and it cannot express “all strings ending with data”.

  • エ

    正解 With wildcards, “?” stands for exactly one arbitrary character, and “*” stands for any string of length zero or more. Blank a must match every string that contains “data”, so it must allow anything (or nothing) both before and after; the correct pattern is “*data*”, which wraps “data” with “*” on both sides. This matches “data” alone, “Xdata”, “dataY”, and “XdataY”. Blank b must match every string that ends with “data”, so putting “*” only in front and fixing “data” at the end gives the correct “*data”, which matches “data” alone and “Xdata”. This combination is a:“*data*”, b:“*data”, so choice エ is correct.

ここがポイント
  • Wildcard basics: “?” represents exactly one arbitrary character, and “*” represents any string of length zero or more (zero characters is also allowed).
  • Grasp the difference in construction: “contains” wraps the word with “*” on both sides, while “ends with” puts “*” only in front and fixes the word at the end.
用語

Your answers