The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Other
> Hire A Programmer
|
Regular Expression Desperation. I'll PayPal $10 to whoever get's it working properly.
Discuss Regular Expression Desperation. I'll PayPal $10 to whoever get's it working properly. in the Hire A Programmer forum on Dev Shed. Regular Expression Desperation. I'll PayPal $10 to whoever get's it working properly. Hire A Programmer forum for employers looking to hire competent developers for on-site positions, and developers looking for an 'on-site' position. List or look for temp, perm, or temp to perm positions here.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 17th, 2003, 02:20 PM
|
|
Self Proclaimed
|
|
Join Date: Nov 2003
Posts: 249
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 10
|
|
|
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.
|

December 17th, 2003, 02:46 PM
|
|
Senior Member
|
|
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,529
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!
|

December 17th, 2003, 02:59 PM
|
|
Self Proclaimed
|
|
Join Date: Nov 2003
Posts: 249
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 10
|
|
|
It poduced an error
|

December 17th, 2003, 03:38 PM
|
 |
Prom night: 1973
|
|
|
|
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);
?>
|

December 17th, 2003, 04:11 PM
|
|
Self Proclaimed
|
|
Join Date: Nov 2003
Posts: 249
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 10
|
|
|
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.
|

December 17th, 2003, 04:20 PM
|
 |
Prom night: 1973
|
|
|
|
|
Last edited by kurious : December 17th, 2003 at 04:40 PM.
|

December 17th, 2003, 05:29 PM
|
|
Self Proclaimed
|
|
Join Date: Nov 2003
Posts: 249
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 10
|
|
|
Thanks,
I'll browse around for a book for my friend.
|

December 17th, 2003, 06:10 PM
|
|
Senior Member
|
|
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,529
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!
|

December 18th, 2003, 08:29 AM
|
|
Self Proclaimed
|
|
Join Date: Nov 2003
Posts: 249
Time spent in forums: 1 h 12 m 56 sec
Reputation Power: 10
|
|
|
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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|