メインコンテンツまでスキップ
バージョン:25.2

matches

  • operator
  • new in 1.81
  • The matches operator tests whether a variable or expression is an exact match for a pattern. One of the operands must be a pattern; the other will be treated as a string value and the operator returns true if the pattern fully matches the entire string. If the pattern matches only part of the string or doesn't match at all, the result of the matches operator will be false.
         put 83 matches <digit,digit> —> true
put <"x", 3 chars, "y"> matches "xyzzy" —> true


  • Note that the matches operator will return true if the pattern can potentially match the full value, even though the usual match of the pattern might not return the full string (due to lazy quantifiers being used):
         put <"$", digits> matches "$895" —> true
put the occurrence of <"$", digits> in "$895" —> "$8"