pattern matching....

Discussion in 'Perl Misc' started by michal.shmueli@gmail.com, Jun 27, 2005.

  1. Guest

    hi,
    i need some help with pattern matching. I have a long txt file which
    has one line that includes a number and the word "matches,". i need to
    extract the number that appears before the "matches" (which some time
    appears with comma as: 1,989 matches,
    and sometimes as 765 matches,

    the whole line is:
    <b><font face="arial,helvetica,sans-serif" size="-1">Items 1 - 10 of
    1,898 matches, sorted by:</b> <select name="sort">

    i did the follow, but nothing happen- couldn't figure out where the
    problem is.

    if (~ /([\d,]+)+matches,\s/) {$page_num=$1;}


    thanks a lot,
    Michal
    , Jun 27, 2005
    #1
    1. Advertising

  2. wrote:
    >
    > <b><font face="arial,helvetica,sans-serif" size="-1">Items 1 - 10 of
    > 1,898 matches, sorted by:</b> <select name="sort">

    -------^
    There is a space there, right?

    > i did the follow, but nothing happen- couldn't figure out where the
    > problem is.
    >
    > if (~ /([\d,]+)+matches,\s/) {$page_num=$1;}


    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jun 27, 2005
    #2
    1. Advertising

  3. Guest

    yes there is. i also try to do:
    if (~ /([\d,]+)+\s+matches,\s/) {$page_num=$1;}

    but it still not working...
    any other hints?
    , Jun 27, 2005
    #3
  4. Guest

    yes there is. i also try to do:
    if (~ /([\d,]+)+\s+matches,\s/) {$page_num=$1;}

    but it still not working...
    any other hints?
    , Jun 27, 2005
    #4
  5. Guest

    actually it's OK now. thanks for the advise.
    , Jun 27, 2005
    #5
    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. DelphiDude
    Replies:
    3
    Views:
    1,160
  2. danpres2k
    Replies:
    3
    Views:
    7,456
    danpres2k
    Aug 25, 2003
  3. CV
    Replies:
    2
    Views:
    582
    Charles DeRykus
    Aug 31, 2004
  4. Marc Bissonnette

    Pattern matching : not matching problem

    Marc Bissonnette, Jan 8, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    220
    Marc Bissonnette
    Jan 13, 2004
  5. Bobby Chamness
    Replies:
    2
    Views:
    215
    Xicheng Jia
    May 3, 2007
Loading...

Share This Page