Skip to main content
Question

Is it possible to use regex in a pattern block?

  • April 4, 2025
  • 2 replies
  • 113 views

  • Ramping Up
  • 1 reply

I am trying to match against a Palo Alto configuration looking for rules that are using a specific destination object.  

 

Rules are under this structure:

config
 devices
  {string}
    vsys
     {string}
       rulebase
        security
         rules
          {rule_name: (string)*}
 

and an example of what I am trying to match is:

 

                "Example Rule" e32ff2ab-a82f-43b6-953e-7e113v624779 {
                  destination [ non-client "External SRC EDL" "Another EDL-wehave"];
 

First line would be the rule name and the second is where I would really want to do the regex match.  The items past “destination” can be a single entry or multiples within []’s.  If there are spaces in the names then the whole name is confined in “’s.  

 

My goal is to find all rules which have “External SRC EDL” in the destination and I can’t quite figure out how to do it.  Any help would be appreciated.

 

 

 

2 replies

Tyson Henrie
Employee
Forum|alt.badge.img+2
  • Employee
  • 75 replies
  • April 4, 2025

@Ivan   That is a question that we worked on before.  There are two different answers in this.  The last answer is using regular expressions.

You will pull the data out as a string first.  the run the regex on that string.  You can not currently put an regex inside the block match. 


  • Author
  • Ramping Up
  • 1 reply
  • April 7, 2025

I was able to modify what was provided in the other post to get what I needed. 

 

Thank you!