---
schema_version: "1"
id: cd5999efca9acf5172d38df9003f637f902317531696be0cb807d0e1bee402d9
title: match
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-core-functions-match.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-core-functions-match
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 50cf4b9612a65e41dc127c818ea837e385557c8711c92ba7351d1dbc5e0d229c
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
# match

## [](#match1)match(text: String, matcher: Regex): Array<String>

Uses a Java regular expression (regex) to match a string and then separates it into capture groups. Returns the results in an array.

Note that you can use `match` for pattern matching expressions that include [case statements](https://docs.mulesoft.com/dataweave/latest/dataweave-pattern-matching).

### [](#parameters)Parameters

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>text</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A string.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>matcher</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A Java regex for matching characters in the <code>text</code>.</p></td>
</tr>
</tbody>
</table>

### [](#example)Example

In this example, the regex matches the input email address and contains two capture groups within parentheses (located before and after the `@`). The result is an array of elements: The first matching the entire regex, the second matching the initial capture group (**) in the regex, the third matching the last capture group (`[a-z]`**).

#### [](#source)Source

```DataWeave
%dw 2.0
output application/json
---
"me@mulesoft.com" match(/([a-z]*)@([a-z]*)\.com/)
```

#### [](#output)Output

```JSON
[
  "me@mulesoft.com",
  "me",
  "mulesoft"
]
```

### [](#example-2)Example

This example outputs matches to values in an array that end in `4`. It uses `flatMap` to iterate over and flatten the list.

#### [](#source-2)Source

```DataWeave
%dw 2.0
var a = '192.88.99.0/24'
var b = '192.168.0.0/16'
var c = '192.175.48.0/24'
output application/json
---
[ a, b, c ] flatMap ( $ match(/.*[$4]/) )
```

#### [](#output-2)Output

```JSON
[  "192.88.99.0/24", "192.175.48.0/24" ]
```

## [](#match2)match(text: Null, matcher: Any): Null

Helper function that enables `match` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._