Hello Monks. This should be a simple problem, but it's 6PM here, and I think that my brain just turned itself off. But I'd like to go home with the problem solved

I'd like to have a regex to match against a UN*X aliases file; the regex should match if a line begins by root: but the string that follows it is different from, say, myself@domain.of-my.own

In short:

I know it is simple, damn; I surely already wrote something like that... but that regex doesn't want to leave my brain for my keyboard...

Any help?

Thanks a lot in advance

Update: I have to feed the regexp into an editfiles section of cfengine; I need to do the job with a single, standard regex

Update: Unfortunately cfengine has no support for PCREs, so if the problem has no solution with plain-old regexes (does it?), I'll have to change the way I work with the problem (by, for example, spawning an external perl -i.bak one-liner. Thanks to everyone of you that took the time to suggest a solution!

Update: Actually, the people of the cfengine have already considered linking against libpcre instead of libre, but nobody come out with a working patch for both the source and the compiler's options. If any monk is able to, that could be great for both cfengine (a great improvement IMHO) and Perl (another conquer, Captain! :-)

Ciao!
--bronto


The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz

In reply to Regex matching a string beginning with "root: " but not containing another string by bronto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.