Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

what is this regex matching?

Last post 03-11-2008, 6:08 PM by Aussie Susan. 2 replies.
Sort Posts: Previous Next
  •  03-11-2008, 12:09 PM 40225

    what is this regex matching?

    I'm delighted that there's actually a regex forum on the Internet where I can get help!  Thanks for providing this website.

    I'm having trouble figuring what this regex is supposed to be matching, can anyone decipher it for me?  This regex was taken from a Solaris/Posix environment and was originally written to scan text-based configuration files.

     Here's a few examples, they're all the same:

    ^[ \t]*uucp[ \t]*(#.*\)$
    ^[ \t]*noaccess[ \t]*(#.*\)$
    ^[ \t]*X11Forwarding=no[ \t]*(#.*\)$
    ^[ \t]*IgnoreRhosts=yes[ \t]*(#.*\)$

  •  03-11-2008, 1:21 PM 40230 in reply to 40225

    Re: what is this regex matching?

    It looks to be search a line that may have a tab or space separators then the  literal text values,  possible a tab or space separators and then a pound sign followed the rest of the text on that line.

    Ex

    uucp    #Some more text. 


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
  •  03-11-2008, 6:08 PM 40242 in reply to 40230

    Re: what is this regex matching?

    Except..... if I read my posix regex correctly, and using the example:

    ^[ \t]*uucp[ \t]*(#.*\)$

    there should either be a literal '(' before the '#' or, if the extended semantics are in use, a ')' at the end of the line. Therefore the example would be either:

      uucp    (#rest of the line

    or

        uucp  #rest of the line)

    Susan
     

View as RSS news feed in XML