Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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:

  • root: myself@domain.of-my.own should NOT match
  • anotherone: myself@domain.of-my.own should NOT match while, say,
  • root: yetanother1@domain.of-my.own SHOULD match

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found