Sensible

The Sensible Developer Hub

Welcome to the Sensible developer hub. You'll find comprehensive guides and documentation to help you start working with Sensible as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Returns lines matching a regular expression. Often, you use a capturing group in this method to narrow down some text in a line you matched in an anchor.

Parameters

Note: For the full list of parameters available for this method, see Global parameters for methods. The following table only shows parameters most relevant to or specific to this method.

keyvaluedescription
id (required)regexThe anchor line is included in this method's match.
pattern (required)Javascript-flavored regular expressionIf the regular expression has capturing groups (for example, ([0-9])([a-z]), Sensible return the contents of the first capturing group (in the preceding example, a single numeric character). Otherwise, Sensible returns the full contents of the matched line. Note you have to double escape characters, since the regex is contained in a JSON object (for example, \\s not \s to represent a whitespace character).
flagsJS-flavored regex flags, default: noneFlags to apply to the regex. for example: "i" for case-insensitive, "g", "m", etc.
stopMatch object. default: noneA Match object to stop extraction. Not included in the method output. If unspecified, matches to end of document.

Examples

The following example narrows down text that's matched in an anchor line (since capturing groups are supported only in the Regex method, not in anchors):

{
  "fields": [
    {
      "anchor": {
        "match": {
          "pattern": "^(19|20)\\d{2}$",
          "type": "regex",
          "minimumHeight": 0.2
        }
      },
      "id": "document_year",
      "type": "number",
      "method": {
        "id": "regex",
        "pattern": "^((19|20)\\d{2})$"
      },
    },
  ]
}

Notes

Regular expressions are also supported in anchor matches. For an example, see the Passthrough method.

Updated 15 days ago


Regex


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.