Previous: Exact Pattern Matching, Up: Pattern Operators



3.6.2.2 Embedded Pattern Matching

Embedded matching tests whether a given pattern appears anywhere within a given string. You specify embedded pattern matching using the in operator. It takes two operands, the first (which must appear on the left-hand side) of type pattern, the second of type string. For example,

         /foo|bar/ in "foobar"

yields true, as does

         /oob/ in "foobar"

but

         /^oob/ in "foobar"

does not, since the text “oob” does not appear the beginning of the string “foobar”. Note, though, that the $ regular expression operator (anchor to end-of-line) is not currently supported, so:

         /oob$/ in "foobar"

currently yields true. This is likely to change in the future. Finally, the !in operator yields the negation of the in operator.