---
schema_version: "1"
id: 489481f5a201b1e9bdeec763a5041e3b77685598e2978aaaa5ee8c4fe3b4bfe0
title: match
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-core-functions-match.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-match
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 6e1e40c0da0fbc2f4ba6253b5e1a48224c0534ef32464fa8544bab51ce3f4c45
description: MuleSoft Documentation Site
release: "2.4"
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 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._