Page 1 of 1

Should I remove whitespace or what?

Posted: Sat Jan 05, 2008 1:18 pm
by Citizen
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Basically I'm working with a CMS that has the entire html input in a single variable, and I need to remove this bunch of html depending on a variable:

[syntax="html"]				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				Main page for the members area.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View your personal homepage.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				You can design / edit your personal webpage and edit your site account settings.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all your messages that have been sent to you.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />

				Submit all of your items in this area including pictures to blogs and much more.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				Edit all of your items you have added on the site.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all of the info on your friends that are in your network.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all of the favorites that you have added to your list.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all of the bulletins posted by your friends.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				Invite your friends to come and join us.
Here's my code that I tried, but didn't work:[/syntax]

Code: Select all

$patterns[] = '/<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				Main page for the members area.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View your personal homepage.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				You can design \/ edit your personal webpage and edit your site account settings.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all your messages that have been sent to you.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>

				Submit all of your items in this area including pictures to blogs and much more.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				Edit all of your items you have added on the site.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all of the info on your friends that are in your network.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all of the favorites that you have added to your list.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all of the bulletins posted by your friends.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				Invite your friends to come and join us./';
$replacements[] = '';


$sHtml = preg_replace($patterns, $replacements, $sHtml);
Also, I had to (.*?) the domain part out so that it could work on more than just the one domain.

Any ideas?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Jan 05, 2008 1:35 pm
by Jonah Bron
Well, I'd say try it. Gotta start somewhere.

Posted: Sun Jan 06, 2008 12:08 am
by s.dot
What exactly are you trying to do? Retrieve the domain names from the images?

Code: Select all

$text = preg_replace('/img src="(.+?)"/im', 'whatever', $text);
echo $text;