# Regex tester

> Test a JavaScript regular expression against your text online. See every match with its position and capture groups, or the syntax error.

Free tool by Orkosi. Page: https://orkosi.com/tools/regex-tester

Write the pattern, paste a sample, see what it catches. Every match is listed with where it starts and what each capture group holds.

1. Type the pattern without the surrounding slashes.
2. Set the flags and paste the text to search.
3. Press Check and read the matches.

## Input

| Field | Type | Required | What it is |
| --- | --- | --- | --- |
| `pattern` | text | yes | Pattern. |
| `flags` | text | no | Flags. Any of d g i m s u y. Default: "g". |
| `text` | text | yes | Text to search. |

## Example

Input:

```json
{
  "pattern": "(\\w+)@(\\w+)\\.com",
  "flags": "g",
  "text": "Write to ana@example.com or ben@orkosi.com, not to carl@example.org."
}
```

Result:

```json
{
  "valid": true,
  "match_count": 2,
  "matches": [
    {
      "index": 9,
      "match": "ana@example.com",
      "groups": "ana | example"
    },
    {
      "index": 28,
      "match": "ben@orkosi.com",
      "groups": "ben | orkosi"
    }
  ],
  "truncated": false
}
```

## Run it

It needs a free Orkosi account, nothing else. No credits are used.

- **A person**: open the page, enter an e-mail once, use the tool.
- **Claude or ChatGPT**: add the Orkosi connector `https://orkosi.com/api/v1/public/mcp` and sign in, or create the free account on the sign-in page. Then call `orkosi_run_free_tool` with `{ "tool": "regex-tester", "input": { … } }`.
- **Any agent or program that can make an HTTP request**:

  1. Once, create the account: `POST https://orkosi.com/api/v1/public/signup` with `{ "name": "…", "email": "…", "terms_accepted": true }` and no key. Ask the person for the e-mail and their agreement to the terms first. The answer carries `data.api_key`, shown once.
  2. Run the tool:

```bash
curl -X POST https://orkosi.com/api/v1/public/tools/regex-tester/run \
  -H "Authorization: Bearer $ORKOSI_API_KEY" -H "Content-Type: application/json" \
  -d '{"input":{"pattern":"(\\w+)@(\\w+)\\.com","flags":"g","text":"Write to ana@example.com or ben@orkosi.com, not to carl@example.org."}}'
```

The answer is `{ "data": { "tool": "…", "result": { … } } }`. A call without a key is answered 401 with the signup steps as data.

## Questions

**Which regex flavour is this?**

JavaScript (ECMAScript), as in Node.js and browsers: named groups, lookbehind and Unicode property escapes with the u flag are supported.

**What do the flags mean?**

g finds every match, i ignores case, m makes ^ and $ match at line breaks, s lets the dot match line breaks, u turns on full Unicode.

**Why did it say my pattern takes too long?**

Nested quantifiers such as (a+)+ can take exponential time on some inputs. The tester stops a pattern after a quarter of a second; rewrite it without the nesting.

All free tools: https://orkosi.com/tools.md
