a quick regex question

Discussion in 'Perl Misc' started by PamelaFoxcroft@gmail.com, Dec 1, 2006.

  1. Guest

    Hi, I want to find all occurences of a string where it looks like this

    testword12345

    So I have a word (actually 10 words) and I want to find all occurenece
    of a any of these 10 words followed by 5 numbers.

    Can anyone help me with this?

    TIA

    Pamela
    , Dec 1, 2006
    #1
    1. Advertising

  2. J.D. Baldwin Guest

    In the previous article, <> wrote:
    > Hi, I want to find all occurences of a string where it looks like this
    >
    > testword12345
    >
    > So I have a word (actually 10 words) and I want to find all occurenece
    > of a any of these 10 words followed by 5 numbers.
    >
    > Can anyone help me with this?


    egrep '(wordone|wordtwo|wordthree|wordfour|etc)[0-9]{5}' foo.txt

    Conversion to Perl non-obvious, depending on what you mean by "find."
    --
    _+_ From the catapult of |If anyone disagrees with any statement I make, I
    _|70|___:)=}- J.D. Baldwin |am quite prepared not only to retract it, but also
    \ / |to deny under oath that I ever made it. -T. Lehrer
    ***~~~~-----------------------------------------------------------------------
    J.D. Baldwin, Dec 1, 2006
    #2
    1. Advertising

  3. Dr.Ruud Guest

    Mirco Wahab schreef:

    > my $combined = join '|', map "$_\\d{5}(?!\\d)", @searchwords;



    ITYM:
    my $combined = join '|', map "\\Q$_\\E\\d{5}(?!\\d)", @searchwords;

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Dec 4, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JKop
    Replies:
    11
    Views:
    845
  2. Matt Price

    quick regex question

    Matt Price, Oct 28, 2004, in forum: Python
    Replies:
    0
    Views:
    613
    Matt Price
    Oct 28, 2004
  3. Steven Bethard

    Re: quick regex question

    Steven Bethard, Oct 28, 2004, in forum: Python
    Replies:
    5
    Views:
    596
    Peter Otten
    Oct 29, 2004
  4. Robert Brewer

    RE: quick regex question

    Robert Brewer, Oct 28, 2004, in forum: Python
    Replies:
    0
    Views:
    620
    Robert Brewer
    Oct 28, 2004
  5. Replies:
    3
    Views:
    716
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page