Skip to content

pattern

strings · scripts/strings/pattern.m

: p = pattern (txt)
: p = pattern (txt, "IgnoreCase", tf)
: p = pattern (pat1, …)

Create a text or expression pattern for string matching (MATLAB compat).

pattern creates a pattern object that can be used with string functions like matches, startsWith, endsWith, contains, count, extract, and replace.

  • pattern("foo") creates a case-sensitive text pattern matching the literal text "foo".
  • pattern("FOO", "IgnoreCase", true) creates a case-insensitive text pattern matching "foo", "FOO", "FoO", etc.
  • pattern(digitsPattern()) wraps another pattern in a text pattern container.
  • pattern("a", "b") concatenates patterns into a single pattern that matches "ab".