# Is Match formatter

> Choose between two outputs based on whether a value matches a regular expression.

Choose between two outputs based on whether a value matches a [regular expression](https://en.wikipedia.org/wiki/Regular_expression).

The Is Match formatter evaluates a regular expression against the placeholder value and outputs one of two formats. Apply it explicitly with the name `ismatch`. The expression goes in the options, in parentheses; the format provides the match output and the no-match output, separated by the split character. Both the match and no-match output are required.

To use braces and parentheses as character literals in your pattern, escape them with a backslash. For example, `\{`, `\}`, `\(`, `\)`.

You can configure settings on the formatter instance. Set the [RegexOptions](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regexoptions) (for example, `IgnoreCase`) to control matching. Change the split character or the placeholder name for matches (the default is `m`). Refer to [Configure Smart Strings](/engine/6000.7/manual/scripting/smart-strings/configure.md) for more information on formatter configuration.

{ /*  Mermaid source kept for the future doc platform; shown as the static image below until mermaid rendering is supported.  */ }

```mermaid
flowchart TD
    full["{value:ismatch(regex):Match output|No match output}"]

    full --> p1["value"]
    full --> p2["ismatch"]
    full --> p3["regex"]
    full --> p4["Match output|No match output"]

    p1 --> d1["Any value"]
    p2 --> d2["Formatter name: ismatch"]
    p3 --> d3["Regular expression"]
    p4 --> d4["Outputs:<br/>match, then no-match"]

    classDef code   fill:#F5F5F5,stroke:#BDBDBD,color:#111;
    classDef orange fill:none,stroke:none,color:#F37021;
    classDef green  fill:none,stroke:none,color:#67BC6B;
    classDef pink   fill:none,stroke:none,color:#EB417A;
    classDef purple fill:none,stroke:none,color:#765BA7;

    class full code;
    class p1,d1 orange;
    class p2,d2 green;
    class p3,d3 pink;
    class p4,d4 purple;

    linkStyle default stroke:#2196F3,stroke-width:1.5px;
```


**Anatomy of the ismatch formatter syntax.:**
![](/api/media?file=/engine/6000.7/media/images/smart-strings-ismatch-formatter.svg)

The first format is used when the value matches; the second is used otherwise. You can output the regular expression's matching groups with a special placeholder named `m`: `{m[0]}` is the whole match and `{m[1]}`, `{m[2]}`, and so on are the captured groups.

| Smart String                                                      | Argument           | Result                 |
| ----------------------------------------------------------------- | ------------------ | ---------------------- |
| `{0:ismatch(^.+123.+$):Okay - {}\|No match content}`              | `"Some123Content"` | Okay - Some123Content  |
| `{0:ismatch(^.+123.+$):Fixed content if match\|No match content}` | `"Some123Content"` | Fixed content if match |
| `{0:ismatch(^.+999.+$):{}\|No match content}`                     | `"Some123Content"` | No match content       |
| `{Currency:ismatch(\p{Sc}):Currency: {m[0]}\|Unknown}`            | `"€ Euro"`         | Currency: €            |

Combine it with the [List formatter](/engine/6000.7/manual/scripting/smart-strings/formatters/list-formatter.md) to test each item in a collection:

| Smart String                                                          | Argument        | Result                        |
| --------------------------------------------------------------------- | --------------- | ----------------------------- |
| `{0:list:{:ismatch(^100\|200\|999$):{:0.00}\|'no match'}\|, \| and }` | `100, 200, 300` | 100.00, 200.00 and 'no match' |

## Additional resources

* [List formatter](/engine/6000.7/manual/scripting/smart-strings/formatters/list-formatter.md)
* [Choose formatter](/engine/6000.7/manual/scripting/smart-strings/formatters/choose-formatter.md)
* [Smart Strings](/engine/6000.7/manual/scripting/smart-strings.md)
