?
Solved

urgent help for pattern matching

Posted on 2003-02-27
11
Medium Priority
?
159 Views
Last Modified: 2010-03-05
hi guys,

i need to get everything which is between

</big> tag and <font color=746884> tag in a webpage and then remove html tags so that i can get text between these two tags in the webpage.


thanks




0
Comment
Question by:fardeen786
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 1

Expert Comment

by:tomclegg
ID: 8038282
Try:


#!/usr/bin/perl

# read stdin into $_
undef $/;
$_ = <>;

if (m|</big\s*>(.*?)<font\b[^>]*\scolor\s*=\s*\"?\#?746884|) {
  print $1;
}
0
 

Author Comment

by:fardeen786
ID: 8038364
hi tom,

i have tried this and its not capturing anything

its actually i have it like this
my $res = $ua->request(HTTP::Request->new(GET => $url));
my $content = $res->content;
and iam using ur command
if ($content=m|</big\s*>(.*?)<font\b[^>]*\scolor\s*=\s*\"?\#?746884|) {
print $1;
}
i dont know mate is anything wrong with my way iam doing it or should not i take $content directly

cheers
0
 

Author Comment

by:fardeen786
ID: 8038884
hi guys and tom,

would anyone would b able to plz help on this


many thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:Extreme66
ID: 8039149
if($string=~/<\/big>([\S+|\s+]+)<font[\S+|\s+]+>/i){
     $content=$1;
}

This works, I tested it, but depending on how your reading your stream you may need to add a switch to read multiple lines... thats all.

It strips your tags and leaves the inbetween content to $content

 Hope this helps..
                  -Jacy-
0
 
LVL 1

Expert Comment

by:tomclegg
ID: 8039427
Try adding "s" flag to the regexp:

#!/usr/bin/perl

# read stdin into $_
undef $/;
$_ = <>;

if (m|</big\s*>(.*?)<font\b[^>]*\scolor\s*=\s*\"?\#?746884|s) {
 print $1;
}
0
 
LVL 1

Expert Comment

by:tomclegg
ID: 8039450
Try adding "s" flag to the regexp:

#!/usr/bin/perl

# read stdin into $_
undef $/;
$_ = <>;

if (m|</big\s*>(.*?)<font\b[^>]*\scolor\s*=\s*\"?\#?746884|s) {
 print $1;
}
0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 8041560
/<\/big>(.*?)<font color\=746884>/s

0
 

Author Comment

by:fardeen786
ID: 8042182
hi ,

thanks to all for all the lovely answers you have given me.

iam able to capture using all of urs coding but iam able able to capture only one occurence

i have in my webpage 5 texts betweeen </big> and <font color=746884> tag

using this codes iam able to capture only one occurence

i have tried putting modifier g with s like evrywhere in the matching iam using g and s together still iam not able to capture other 4 occurences.

can anybody help please

thanks a lot again,

cheers
0
 
LVL 1

Accepted Solution

by:
tomclegg earned 60 total points
ID: 8043148
#!/usr/bin/perl

# read stdin into $_
undef $/;
$_ = <>;

while (m|</big\s*>(.*?)<font\b[^>]*\scolor\s*=\s*\"?\#?746884|sg) {
  print "$1\n";
}
0
 

Author Comment

by:fardeen786
ID: 8043459
hi,

thanks tom it really worked! thanks a lot mate!

what about the other question mate!

if u could help me on that i would be grateful


regards and best wishes
fardeen
0
 

Author Comment

by:fardeen786
ID: 8043467
thanks mate
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question