Skip to main content

blockPattern

blockPattern(text: String) : PatternBlocks<{}>

The blockPattern(text) function can be used to parse a block pattern from a string. For example, the following query matches a set of patterns against device configurations, where the patterns are obtained from HTTP sources using the blockPattern function:

foreach device in network.devices
foreach httpSource in network.externalSources.httpSources
foreach endpoint in httpSource.endpoints
where endpoint.statusCode == 200
let patternSource = endpoint.responseBody
where isPresent(patternSource)
foreach match
in blockMatches(device.files.config, blockPattern(patternSource))
select { deviceName: device.name, patternSource, matchedBlocks: match.blocks }

Note that the pattern source must not contain any capture groups.

See also

Types