Contact Free trial Login

scan

scan(String, Regex): Array<Array<String>>

Returns a list (array) with all of the matches found within the given string.

Each match is returned as an array that contains the complete match followed by any capture groups in your regular expression (if present).

Parameters

Name Description

text

The text to scan (String type).

regex

A regular expression that describes the pattern to look for in the text.

Example

In the example, the regex describes an email address. It contains two capture groups, the characters before and after the @. It produces an an array matching the two email addresses in the input string. Each match is an array of three elements: The first is the entire email address, and the second and third are matches to the regex capture groups.

Source

%dw 2.0
output application/json
---
"hello" : "anypt@mulesoft.com,max@mulesoft.com" scan /([a-z]*)@([a-z]*).com/

Output

{
  "hello": [
    [
      "anypt@mulesoft.com",
      "anypt",
      "mulesoft"
    ],
    [
      "max@mulesoft.com",
      "max",
      "mulesoft"
    ]
  ]
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub