---
schema_version: "1"
id: 8abd477d57d2d607ff6f57bd92ae626ff5c6c1540b0ed64a168880ec675d5e01
title: match
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.7/dw-core-functions-match.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.7/dw-core-functions-match
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 58e2636f16a9b088ffb1eaea63f4b140a75b26d0849130a97a932ae512fedfe0
description: MuleSoft Documentation Site
release: "2.7"
latest: false
---
# match

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

Java 正規表現 (regex) を使用して文字列を照合して各キャプチャグループに分割します。結果を配列で返します。

`match`​ は、​ [case ステートメント](https://docs.mulesoft.com/dataweave/latest/dataweave-pattern-matching)​を含むパターン一致式で使用できます。

### [](#パラメーター)パラメーター

<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">名前</th>
<th class="tableblock halign-left valign-top">説明</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">文字列。</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"><code>text</code>​ 内の文字を照合する Java 正規表現。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例の正規表現は入力のメールアドレスを照合し、括弧内に 2 つのキャプチャグループ (​`@`​ の前と後) を含みます。結果は要素の配列です。1 つ目は正規表現全体と一致し、2 つ目は正規表現内の最初のキャプチャグループ (​**​) と一致し、3 つ目は最後のキャプチャグループ (​`[a-z]`**​) と一致します。

#### [](#ソース)ソース

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

#### [](#出力)出力

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

### [](#例-2)例

次の例では、末尾が ​`4`​ である配列内の値への一致を出力します。これは ​`flatMap`​ を使用して、リストを反復処理し、フラット化します。

#### [](#ソース-2)ソース

```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]/) )
```

#### [](#出力-2)出力

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

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

`match`​ を ​`null`​ 値に使用できるようにするヘルパー関数。

_DataWeave バージョン 2.4.0 で導入されました。_