SunQuest
           Hire A Programmer
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherHire A Programmer

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old December 17th, 2003, 02:20 PM
Hero Doug Hero Doug is offline
Self Proclaimed
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 249 Hero Doug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 5
Regular Expression Desperation. I'll PayPal $10 to whoever get's it working properly.

For someone who knows what their doing this shouldn't be too hard; unfortunately for me, this my first time using regular expressions, and I don't have the luxury, or patience to learn them right now.

I'll send $10 USD to anyone who gets it working the way I want. (I'll be sending it through Pay Pal, so you may need to have a premier account, I'm not sure.)

I have written out a detailed explanation of the problem, with examples of what I need it to do.

Please test it using the url http://www.yahoo.com. It has 3 JavaScript code blocks separated by text, so this will be a good test page for multiple uses of JavaScript.

The other page is http://www.brainhosting.com. They have one JavaScript code block at the top, so this will be a good test page for just one.

The first person to post the working code is the winner. If it doesn't work, I'll move on until I get one that does work. (So please test it yourself before you post it)

Disclaimer: You agree to not try and hold any property rights to the regular expression, and that it shall be 100% royalty free. (I've learnt the hard way to cover my butt)

Please visit http://www.arcanenexus.com for a more detailed explination.

Thanks to all who help, and congrats to the first to get it working.

Reply With Quote
  #2  
Old December 17th, 2003, 02:46 PM
Fataqui Fataqui is offline
Senior Member
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,530 Fataqui User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 42 sec
Reputation Power: 0
Hi


Try something like this....

untested but it should work!

PHP Code:
<?

    
function strip_html($str) {
        
$tab get_html_translation_table(HTML_ENTITIES);
        
$tab array_flip($tab);
        return 
strtr($str$tab);
    }

    function 
text_mode($str) {
        return 
strip_html(preg_replace(array("'<(SCRIPT|STYLE)[^>]*?>.*?</(SCRIPT|STYLE)[^>]*?>'si""'(\\r|\\n)'""'<BR[^>]*?>'i""'<P[^>]*?>'i""'<\\/?\\w+[^>]*>'e"), array("""""\\r\\n""\\r\\n\\r\\n"""), $str));
    }

$page file_get_contents('http://www.yahoo.com/');
$page text_mode($page);


echo 
$page;


?>





F!

Reply With Quote
  #3  
Old December 17th, 2003, 02:59 PM
Hero Doug Hero Doug is offline
Self Proclaimed
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 249 Hero Doug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 5
It poduced an error

Reply With Quote
  #4  
Old December 17th, 2003, 03:38 PM
kurious's Avatar
kurious kurious is offline
Prom night: 1973
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2001
Posts: 1,152 kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 36 m 22 sec
Reputation Power: 11
preg_replace needs to be set to ignore newlines. The '/s' modifier does it.

Code:
<?php

$domain = 'http://www.yahoo.com/';

$open = fopen($domain, "r");

$readone = fread($open, 200000);
$readtwo = stristr($readone, '<body');
$readthree = preg_replace( "/<script[^>]+>.*?<\/script>/is", "", $readtwo);  //<-- extra modifier here
//$readthree = eregi_replace("<script(.*)<\/script>/u", "", $readtwo);

$read = strip_tags($readthree);

fclose($open);

$filtered = eregi_replace(" a ", " ", $read);
$$filtered = eregi_replace(" about ", " ", $filtered);
$$filtered = eregi_replace(" after ", " ", $$filtered);
$$filtered = str_replace('"', ' ', $$filtered);

echo trim($$filtered);

?>

Reply With Quote
  #5  
Old December 17th, 2003, 04:11 PM
Hero Doug Hero Doug is offline
Self Proclaimed
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 249 Hero Doug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 5
Thanks kurious, it did everything I needed it to do. I've tested it on 5 five sites and were formatted perfectly. (well, still a few bugs to work out, the source of the formatted pages have a LOT of white space)

Send me your Pay Pal details. (sales@arcanenexus.com) and I'll send you all money as I said I would.

Thanks again.

Reply With Quote
  #6  
Old December 17th, 2003, 04:20 PM
kurious's Avatar
kurious kurious is offline
Prom night: 1973
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2001
Posts: 1,152 kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 36 m 22 sec
Reputation Power: 11
>Send me your Pay Pal details.

That's not necessary. It's the season of good will

If you feel the need to pay, you can buy something for rycamor He's helped me out a lot and has an Amazon wishlist at http://www.amazon.com/gp/registry/r...id=HBFZZHYLLOGH

Last edited by kurious : December 17th, 2003 at 04:40 PM.

Reply With Quote
  #7  
Old December 17th, 2003, 05:29 PM
Hero Doug Hero Doug is offline
Self Proclaimed
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 249 Hero Doug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 5
Thanks,

I'll browse around for a book for my friend.

Reply With Quote
  #8  
Old December 17th, 2003, 06:10 PM
Fataqui Fataqui is offline
Senior Member
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,530 Fataqui User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 42 sec
Reputation Power: 0
Hi

First off, WHAT ERROR DID IT GIVE YOU, you say it gave you a error, but you don't say what the error is! After trying my code on 3 servers I see no error, I think you full of bull!





http://ms.ya-right.net/yahoo.php


F!

Reply With Quote
  #9  
Old December 18th, 2003, 08:29 AM
Hero Doug Hero Doug is offline
Self Proclaimed
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 249 Hero Doug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 5
Fatal error: Call to undefined function: file_get_contents() in c:\phpdev\www\test.php on line 28

This line specifically

$page = file_get_contents('http://www.yahoo.com/');

Tested on a windows box

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherHire A Programmer > Regular Expression Desperation. I'll PayPal $10 to whoever get's it working properly.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway