Skip to content

How to get a array of strings matched to a regex #1687

Answered by BernieWhite
JonasCordsen asked this question in Q&A
Discussion options

You must be logged in to vote

@JonasCordsen You are correct it is related to the match expression expecting a string.

Try this:

---
# Synopsis:
apiVersion: github.com/microsoft/PSRule/v1
kind: Rule
recommend: 'VPN Local gateways onPremise network should be a subnet'
metadata:
  name: 'Local.YAML.localNetworkGateways.Subnet'
spec:
  type:
    - 'Microsoft.Network/localNetworkGateways'
  condition:
    allOf:
      - field: 'properties.localNetworkAddressSpace.addressPrefixes'
        isArray: true
      - field: 'properties.localNetworkAddressSpace.addressPrefixes'
        allOf:
          - field: .
            match: '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JonasCordsen
Comment options

Answer selected by JonasCordsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants