pattern matching....

M

michal.shmueli

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
 
G

Gunnar Hjalmarsson

<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;}
 
M

michal.shmueli

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

but it still not working...
any other hints?
 
M

michal.shmueli

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

but it still not working...
any other hints?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top