Skip to content
moxon home

Regex Tester

The /regex endpoint tests a regular expression pattern against a text string and returns structured match results including capture groups and named groups.

gethttps://api.moxon.dev/v5/regex

Use Cases

Validate regex patterns during development, extract structured data from raw text, debug complex capture groups, or build regex-powered search previews without running server-side code.

Try itget/v5/regex

Parameters

  • patternstringrequired

    The regular expression pattern to test (max 200 characters).

  • textstringrequired

    The text to test the pattern against (max 1000 characters).

  • flagsstringoptional

    Regex flags to apply. Accepted: i, m, s, u. The g flag is always applied.

Response Fields

  • validboolean

    true if the pattern is a valid regex

  • patternstring

    The pattern as provided

  • flagsstring

    The effective flags used (always includes g)

  • countnumber

    Total number of matches found

  • matchesobject[]

    Array of match objects

  • matches[].matchstring

    The full matched string

  • matches[].indexnumber

    Start index of the match in the text

  • matches[].groupsstring[]

    Array of numbered capture group values (empty string if unmatched)

  • matches[].namedGroupsobject

    Key-value map of named capture groups ((?<name>...))

Code Examples

Error Handling

  • 400Please provide a pattern (?pattern=...)The pattern parameter is missing
  • 400Please provide a text (?text=...)The text parameter is missing
  • 400Pattern must be at most 200 charactersThe pattern exceeds the maximum length
  • 400Text must be at most 1000 charactersThe text exceeds the maximum length
  • 400Invalid flag: {flag}. Accepted flags: g, i, m, s, uOne or more flags are not supported
  • 400Invalid regular expressionThe pattern is not a valid regular expression