Skip to content

平成30年度 春期 ITパスポート試験 問85

This question's explanation and your answers so far.

問85
頻出度★☆☆

ワイルドカードを使って “*A*.te??” の表現で文字列を検索するとき, ①~④ の文字列のうち, 検索条件に一致するものだけを全て挙げたものはどれか。ここで, ワイルドカードの “?” は任意の1文字を表し, “*” は0個以上の任意の文字から成る文字列を表す。 ① A.text ② AA.tex ③ B.Atex ④ BA.Btext

出典 平成30年度 春期 ITパスポート試験 問85
解説

問 85

  • ア

    正解 Break the pattern 「*A*.te??」 down symbol by symbol and match it. 「*」 stands for a string of zero or more arbitrary characters, 「?」 stands for any single character, and the pattern must match the entire string. So the matching condition is: the string contains A somewhere, then “.te” follows, and it ends with any two characters. In ①“A.text”, the leading A (the preceding 「*」 matches zero characters) → “.te” → the remaining “xt” is exactly two characters matching 「??」, so it matches all the way to the end with nothing missing or left over. None of the other items in ①-④ match, so listing only those that satisfy the condition gives just “①”, and the correct answer is choice ア.

  • Incorrectイ

    In ②“AA.tex”, there is only the single character “x” after “.te”, which falls short of the two characters required by 「??」, so it does not match. Only ① matches, so choice イ, which also includes ②, is wrong.

  • Incorrectウ

    As noted above, ② falls short of two characters and does not match. In ③“B.Atex”, the “.” comes before A, and A is not followed by “.te”, so it does not match. In ④“BA.Btext”, the only “.” is directly followed by “B” and does not continue with “te”, so it does not match. None of them satisfy the condition, so choice ウ, which lists ②, ③, ④, is wrong.

  • Incorrectエ

    In ③“B.Atex”, A is not followed by “.te”, and in ④“BA.Btext”, the “.” is not directly followed by “te”, so neither matches 「*A*.te??」. Choice エ, which lists ③, ④, is therefore wrong.

ここがポイント
  • Wildcard basics: 「*」 represents a string of zero or more arbitrary characters, 「?」 represents any single character, and the pattern must match the entire target string being searched.
  • 「?」 always consumes exactly one character, so 「te??」 requires exactly two characters after “te”. The key point is to strictly count the positions of the fixed parts (such as “.” and “te”) and the number of characters in the variable parts, then perform the match.
用語

Your answers