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
Regular expression problem
Old 12-09-2005, 08:06 AM Regular expression problem
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
I'm making a template system for my news poster, with some special tags. Everything between {if!comments}{/if!comments} should for example be showed when we're not on a comment page, but not when we are. Therefore I have to remove it from the template when comments are showed. I use
PHP Code:
preg_replace('#(\{if!comments\})+(.*?)+(\{/if!comments\})#'''$template); 
, but that doesn't remove all of them. What am I doing wrong?
__________________

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

Last edited by Orodreth; 12-09-2005 at 08:10 AM..
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
 
Register now for full access!
Old 12-09-2005, 08:17 AM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
The regex seems to be fine. When does it NOT remove them? Do the comments ever contain newline characters? If so, your regex isn't accounting for that.
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 12-09-2005, 08:26 AM
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
Hey, you're right. I does remove it when there are no new lines. How do I make it work with newlines too?

Great, I found it. Thanks alot.
__________________

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

Last edited by Orodreth; 12-09-2005 at 08:32 AM..
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Reply     « Reply to Regular expression problem
 

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.16113 seconds with 12 queries