Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-23-2008, 11:00 AM Preg_Replace Help
Novice Talker

Posts: 6
Trades: 0
I have a little coding I need help with and hope somebody can lend assistance.

Here is what I am trying to do, currently this works very well but I need to not replace any image tag that has an alt tag in it. Thanks.

preg_replace( "#<img(?:.+?)src=[\"'](\S+?)['\"][^>]+?>#is", "image holder", $comment );
dvancouver is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-23-2008, 04:21 PM Re: Preg_Replace Help
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Can you provide an example of what you want replaced and indicate what makes it qualify for replacement?
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 09-23-2008, 05:36 PM Re: Preg_Replace Help
Novice Talker

Posts: 6
Trades: 0
Absolutely!

I have a forum where I hide images from displaying to certain groups, now I can hide the images that are posted no problem. It's the smilies that are the issue, they get hidden to and I don't want that. There is a special tag inside the smilie image tag called emoid, so thought I could use a delimiter to accomplish it, here is an example of what an img might looks like:
Code:
img src="/images/smile.gif" emoid=":)" alt="smile.gif"
So only images that are not smilies I want to hide, show smilies.
dvancouver is offline
Reply With Quote
View Public Profile
 
Old 09-23-2008, 06:29 PM Re: Preg_Replace Help
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Hmmm... I'll have to think about this a bit. A little swamped right now, but I'll try to look at it tonight. Maybe someone else can see a solution in the meantime.

Oh, and thanks for providing the extra code!
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 09-23-2008, 11:39 PM Re: Preg_Replace Help
Novice Talker

Posts: 6
Trades: 0
No problem! Let me know if you come up with anything cause I keep getting zip.
dvancouver is offline
Reply With Quote
View Public Profile
 
Old 09-24-2008, 01:14 AM Re: Preg_Replace Help
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Look at this, I hope it will help you
http://www.webmaster-talk.com/php-fo...tml#post762639
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 09-24-2008, 10:03 AM Re: Preg_Replace Help
Novice Talker

Posts: 6
Trades: 0
I am not really seeing a solution there that I understand. Thanks for the example though.
dvancouver is offline
Reply With Quote
View Public Profile
 
Old 09-24-2008, 12:46 PM Re: Preg_Replace Help
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
I don't see how to do this with regular expressions. They look for what does exist, not the converse (afaik). If you had a characteristic about the other links which was not in the emoticons one, then you could ensure its presence in the replacement regex.

What I would do instead, is adjust the forum code to apply your reg ex before emoticons are added, if possible.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 09-24-2008, 01:00 PM Re: Preg_Replace Help
Novice Talker

Posts: 6
Trades: 0
Though if I apply the regex when the emoticon is added how does that stop the link from being processed by the code?
dvancouver is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Preg_Replace Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50998 seconds with 12 queries