Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^12: Bind zone file search

by ranceh (Initiate)
on Sep 27, 2012 at 13:53 UTC ( #996010=note: print w/replies, xml ) Need Help??

in reply to Re^11: Bind zone file search
in thread Bind zone file search

This is really close, but not quite right.

This regex is matching commented zone directives and if the comment is found after the real one is overwriting good answers for bad ones.

I need to avoid commented stanzas. Since commented stanzas include comment characters prior to the match of zone, I think I need a way to ensure that matches on the word zone. Am I thinking correctly?

Replies are listed 'Best First'.
Re^13: Bind zone file search
by Kenosis (Priest) on Sep 27, 2012 at 15:59 UTC

    By "commented," do you mean those containing either the "//" or "#" characters? Do you want to avoid all zone stanzas that contain those characters and use only those zone stanzas that don't contain those comment characters, i.e., "//" and "#"?

      right, I need to avoid stanzas that begin with the // or #

        Try the following modified regex in the subroutine:

        /(?<!#|\/)\s*zone\s+"([^"]+)".+?masters\s+{[\s#\/]*([a-zA-Z0-9.-]+)[\s +#\/;]*}/sg


        (?<!#|\/)\s*zone ^ ^ ^ | | | | | + - 0+ whitespaces | + - Match "zone" and 0+ whitespaces that are not preceded by an " +#" or "/" + - Negative lookbehind

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996010]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-04-20 05:48 GMT
Find Nodes?
    Voting Booth?