Skip to content

regexp

Match a regular expression against a string.

k = regexp(str, expr)

Searches str for matches of the regular expression expr and returns a vector of starting indices for each match.

MathJet’s regexp currently supports only the 2-argument basic form — the multi-output / option-flag forms ('match', 'tokens', 'split', 'once', etc.) accepted by MATLAB are not yet implemented.

regexp('foo123bar456', '\d+') % [4 10] indices of digit-runs
  • regexpi — Match a regular expression against a string (case-insensitive).
  • strfind — Find one string within another.
  • strrep — Replace all occurrences of a substring.