CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
How to match tag 7 time

 



perlkid
stranger

Oct 23, 2000, 10:14 PM

Post #1 of 4 (1808 views)
How to match tag 7 time Can't Post

 
How can I use s///; to take out the <tr>.*</tr> the on the seventh occurance.

I though that

$table =~ s!{7}<TR>(.*?)</TR>!!sg;

That way the perl would not start taking out <TR> blocks until it finds it 7 times.

Is this possible?

Thanks,

perlkid


dws
Deleted

Oct 24, 2000, 4:58 PM

Post #2 of 4 (1808 views)
Re: How to match tag 7 time [In reply to] Can't Post

If you approach this with the idea that it can be done with a single regular expression, it's gonna hurt (even if it can be done).

Try breaking the problem down. Use regular expressions to cut pieces off of the front of the source string (appending them to an output string) until you reach the first <tr>. Then cut/append 7 <tr>.*?</tr> pairs, then drop the remaining pairs, then append whatever is left of the source string to the output string.


perlkid
stranger

Oct 25, 2000, 12:14 PM

Post #3 of 4 (1808 views)
Re: How to match tag 7 time [In reply to] Can't Post

  
Ok Thanks dws, I got it working like that now.

Thanks Mate,

perlkid


Jasmine
Administrator

Jan 16, 2001, 2:49 PM

Post #4 of 4 (1782 views)
Re: How to match tag 7 time [In reply to] Can't Post

Answer in the Perl FAQ:

How do I change the Nth occurrence of something?


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives