github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/regexall.mdx (about)

     1  ---
     2  page_title: regexall - Functions - Configuration Language
     3  description: >-
     4    The regex function applies a regular expression to a string and returns a list
     5    of all matches.
     6  ---
     7  
     8  # `regexall` Function
     9  
    10  `regexall` applies a
    11  [regular expression](https://en.wikipedia.org/wiki/Regular_expression)
    12  to a string and returns a list of all matches.
    13  
    14  ```hcl
    15  regexall(pattern, string)
    16  ```
    17  
    18  `regexall` is a variant of [`regex`](/language/functions/regex) and uses the same pattern
    19  syntax. For any given input to `regex`, `regexall` returns a list of whatever
    20  type `regex` would've returned, with one element per match. That is:
    21  
    22  - If the pattern has no capture groups at all, the result is a list of
    23    strings.
    24  - If the pattern has one or more _unnamed_ capture groups, the result is a
    25    list of lists.
    26  - If the pattern has one or more _named_ capture groups, the result is a
    27    list of maps.
    28  
    29  `regexall` can also be used to test whether a particular string matches a
    30  given pattern, by testing whether the length of the resulting list of matches
    31  is greater than zero.
    32  
    33  ## Examples
    34  
    35  ```
    36  > regexall("[a-z]+", "1234abcd5678efgh9")
    37  [
    38    "abcd",
    39    "efgh",
    40  ]
    41  
    42  > length(regexall("[a-z]+", "1234abcd5678efgh9"))
    43  2
    44  
    45  > length(regexall("[a-z]+", "123456789")) > 0
    46  false
    47  ```
    48  
    49  ## Related Functions
    50  
    51  - [`regex`](/language/functions/regex) searches for a single match of a given pattern, and
    52    returns an error if no match is found.
    53  
    54  If Terraform already has a more specialized function to parse the syntax you
    55  are trying to match, prefer to use that function instead. Regular expressions
    56  can be hard to read and can obscure your intent, making a configuration harder
    57  to read and understand.