{
  "name": "Replace-by-pattern options and token syntax: MATLAB regexprep, GNU Octave regexprep and Python re.sub",
  "description": "Compares how three documented tools express common regexprep tasks (replace only some matches, ignore case, reuse a captured group, reuse the whole match, compute the replacement). Compiled from the official MathWorks, GNU Octave and Python documentation pages; a cell reads 'Not documented in the page read' where the page read does not state the feature.",
  "page": "https://casrai.org/guides/matlab-regexprep",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-16T21:57:57Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Task",
      "unit": "",
      "description": ""
    },
    {
      "name": "MATLAB regexprep",
      "unit": "",
      "description": ""
    },
    {
      "name": "GNU Octave regexprep",
      "unit": "",
      "description": ""
    },
    {
      "name": "Python re.sub",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Task": "Replace only the first match",
      "MATLAB regexprep": "'once' option",
      "GNU Octave regexprep": "'once' option",
      "Python re.sub": "count=1"
    },
    {
      "Task": "Replace only the first N matches",
      "MATLAB regexprep": "Numeric option N",
      "GNU Octave regexprep": "Not documented in the page read",
      "Python re.sub": "count=N"
    },
    {
      "Task": "Ignore case when matching",
      "MATLAB regexprep": "'ignorecase' option",
      "GNU Octave regexprep": "'ignorecase' option (as for regexp)",
      "Python re.sub": "flags=re.IGNORECASE or inline (?i)"
    },
    {
      "Task": "Insert the Nth captured group",
      "MATLAB regexprep": "$N in replace",
      "GNU Octave regexprep": "$i in repstr",
      "Python re.sub": "\\N or \\g in repl"
    },
    {
      "Task": "Insert the whole match",
      "MATLAB regexprep": "$0 or $& in replace",
      "GNU Octave regexprep": "Not documented in the page read",
      "Python re.sub": "\\g in repl"
    },
    {
      "Task": "Insert a named group",
      "MATLAB regexprep": "$ in replace",
      "GNU Octave regexprep": "Not documented in the page read",
      "Python re.sub": "\\g in repl"
    },
    {
      "Task": "Compute the replacement with code",
      "MATLAB regexprep": "${cmd} in replace",
      "GNU Octave regexprep": "Not documented in the page read",
      "Python re.sub": "repl as a function receiving a Match object"
    }
  ],
  "sources": [
    {
      "title": "MathWorks: regexprep",
      "url": "https://www.mathworks.com/help/matlab/ref/regexprep.html",
      "accessed": "2026-11-12"
    },
    {
      "title": "GNU Octave: Searching and Replacing in Strings",
      "url": "https://docs.octave.org/latest/Searching-and-Replacing-in-Strings.html",
      "accessed": "2026-11-12"
    },
    {
      "title": "Python: re - Regular expression operations",
      "url": "https://docs.python.org/3/library/re.html",
      "accessed": "2026-11-12"
    }
  ]
}