Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: calling all reg exp masters!!
by ikegami (Patriarch) on Jan 26, 2005 at 19:14 UTC

    At the opposite end of the spectrum:

    m{ S-adenosyl-L-methionine-dependent[ ]methyltransferases | ATPase[ ]domain[ ]of[ ]HSP90[ ]chaperone/DNA[ ]topoisomerase[ ]II/h +istidine[ ]kinase | Q8PHW2_XANAC_Q8PHW2; }x
      You forgot the anchors.
      m{ ^ (?: S-adenosyl-L-methionine-dependent[ ]methyltransferases | ATPase[ ]domain[ ]of[ ]HSP90[ ]chaperone/DNA[ ]topoisomerase[ ]II/h +is +tidine[ ]kinase | Q8PHW2_XANAC_Q8PHW2; ) \z }x;
Re: calling all reg exp masters!!
by dragonchild (Archbishop) on Jan 26, 2005 at 19:09 UTC
    $string =~ /./;

    You want to figure out what you want to exclude as well as what you want to include.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: calling all reg exp masters!!
by talexb (Chancellor) on Jan 26, 2005 at 19:10 UTC

    Well, I guess

    /^.+$/
    would match all of them. But maybe you want a non-trivial answer. I can't tell.

    What are you trying to extract from each of those lines?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: calling all reg exp masters!!
by Ardemus (Beadle) on Jan 26, 2005 at 21:32 UTC
    If this is a serious question please provide more details about your application, and the data's context.

    I assume that you want to match data in the form of those three individual strings.

    1. Your first string can be matched easily enough: /[A-Z]-\w+-[A-Z]-\w+-\w+ \w+/
    2. Your second string requires more advanced knowledge of your data, and what to look for to determine the boundaries.
    3. The third is also fairly easy (I'm assuming that the first and last strings always match): /([0-9A-Z]{5,5})_[0-9A-Z]{5,5}_\1/

    This code is just off the top of my head, but the basic idea should be plain. Clearly we'd have to know more about the variations allowed for the data, and the data that we need to *avoid* matching.


    You can always combine multiple searches into one giant 'or' fest, /search1|search2|search3/. However that's much more confusing to read, harder to debug, and much slower than individual searches.

    With a deep knowledge of your data, and what you are trying to match, you *might* be able to create an aggregate reg-ex that was more efficient than three searches, but probably not.

    Ardemus - "This, right now, is our lives."