Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-14-2008, 09:17 PM   PM User | #1
Christian271
New Coder

 
Join Date: Jun 2008
Location: Vista, CA
Posts: 59
Thanks: 3
Thanked 0 Times in 0 Posts
Christian271 is an unknown quantity at this point
deleting text with 4 varying characters from a string stored in a variable

I use this code to get the source of line 25 of dragcave.net.
PHP Code:
$lines file('http://dragcave.net/user/Christian271');
$line $lines[25]; 
I need to delete all
Code:
<td><a href="/viewdragon/HkLG">View</a></td>
from it but the HkLG is going to be different every time.
I tried this
PHP Code:
$re '';
$pattern '/(<td><a href="/viewdragon/)....(">View</a></td>)/';
$line2 preg_replace($pattern$re$line);
echo(
$line2); 
but I get the error 'Warning: preg_replace() [function.preg-replace]: Unknown modifier 'v' in /home/a9196005/public_html/test.php on line 16' line 16 is $line2 = preg_replace($pattern, $re, $line); Any ideas?
__________________
Visit my galley
Christian271 is offline   Reply With Quote
Old 08-15-2008, 12:09 AM   PM User | #2
binaryWeapon
Regular Coder

 
Join Date: Sep 2007
Location: AZ, USA
Posts: 685
Thanks: 6
Thanked 46 Times in 46 Posts
binaryWeapon is on a distinguished road
Does escaping the first v work? Like this:
Code:
$pattern = '/(<td><a href="\/viewdragon/)....(">View</a></td>)/';
binaryWeapon is offline   Reply With Quote
Old 08-15-2008, 02:11 AM   PM User | #3
Christian271
New Coder

 
Join Date: Jun 2008
Location: Vista, CA
Posts: 59
Thanks: 3
Thanked 0 Times in 0 Posts
Christian271 is an unknown quantity at this point
now it's saying 'Warning: preg_replace() [function.preg-replace]: Unknown modifier ')' in /home/a9196005/public_html/test.php on line 16'
__________________
Visit my galley
Christian271 is offline   Reply With Quote
Old 08-15-2008, 03:12 AM   PM User | #4
binaryWeapon
Regular Coder

 
Join Date: Sep 2007
Location: AZ, USA
Posts: 685
Thanks: 6
Thanked 46 Times in 46 Posts
binaryWeapon is on a distinguished road
Well then escape the other one. While your at it, escape the other ones too.
Code:
$pattern = '/(<td><a href="\/viewdragon\/)....(">View<\/a><\/td>)/';
binaryWeapon is offline   Reply With Quote
Old 08-15-2008, 04:35 AM   PM User | #5
Christian271
New Coder

 
Join Date: Jun 2008
Location: Vista, CA
Posts: 59
Thanks: 3
Thanked 0 Times in 0 Posts
Christian271 is an unknown quantity at this point
It works! I don't know why I didn't think of that. So that's two times you've helped (you tried to help me find the URL of a frame with javascript) Thanks so much!
__________________
Visit my galley
Christian271 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:00 AM.


Advertisement
Log in to turn off these ads.