---
schema_version: "1"
id: e5af97d49d0346c1e560adcdf6bf4ffc3ba2773b03415dd9a6c06478ffe05d6d
title: countCharactersBy
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-strings-functions-countcharactersby.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-strings-functions-countcharactersby
source_site: docs.mulesoft.com
content_type: documentation
content_hash: da0ddcaa7c3d343601256c24d2a4cbbff385fbaedfe775e8e1de9fbef2ed7b58
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# countCharactersBy

## [](#countcharactersby1)countCharactersBy(text: String, predicate: (character: String) -> Boolean): Number

文字列の各文字を反復処理する式が ​`true`​ を返す回数を数えます。

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

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

<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"><code>predicate</code>​ が適用される文字列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>predicate</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>text</code>​ 文字列の各文字に適用する式。この式では Boolean (ブール) 値を返す必要があります。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、文字列の桁数を数えています。

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

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
"42 = 11 * 2 + 20" countCharactersBy isNumeric($)
```

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

```Json
7
```

## [](#countcharactersby2)countCharactersBy(text: Null, predicate: (character: Nothing) -> Any): Null

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

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