ramli Posted April 17, 2007 Share Posted April 17, 2007 I want to replace the text between the quote]/quote] including the [] itself to [...] So : fdhskfsjkfhdsjkfhdskjlfhdskjfhldskjfhj quote] hier een heel verhaal, altijd ierst anders aoiufhv;awoghaer;ogihja;goiherw /quote] jasdhklasdkjh Should be: fdhskfsjkfhdsjkfhdskjlfhdskjfhldskjfhj [...] jasdhklasdkjh Can anybody assist me with this problem ? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/ Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 What about this <?php $string = 'Hello [test1] how are you [test2]'; $pattern[] = '/\[test1\]/'; $pattern[] = '/\[test2\]/'; $replacement[] = 'world'; $replacement[] = 'today'; echo preg_replace($pattern, $replacement, $string); ?> Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231559 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 oops mis read try <?php $string = 'Hello [quote] how are you [\quote] sorry'; $pattern[] = '/\[quote\].*\[\quote]/'; $replacement[] = 'oops'; echo preg_replace($pattern, $replacement, $string); die; ?> Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231560 Share on other sites More sharing options...
ramli Posted April 17, 2007 Author Share Posted April 17, 2007 It returns "Hello quote] how are you \quote] sorry" i guess this is not your intention is the pattern correct ? i dont realy know but thats the only thing i can think of ... (removed [) Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231564 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 humm this works <?php $string = 'Hello [quote] how are you [\quote] sorry'; $pattern[] = '/\[quote\].*\[\\\quote\]/'; $replacement[] = 'oops'; echo preg_replace($pattern, $replacement, $string); die; ?> Updated Sorry still learning RegEx Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231567 Share on other sites More sharing options...
maxic0 Posted April 17, 2007 Share Posted April 17, 2007 Can someone explain this line to me please? $pattern = '/\[quote\].*\[\\\quote]/'; Whats with all the \\\ ? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231577 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 please don't hi jack other members posts. the patten is a RegEx Patten in simple terms \\\ means \ Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231580 Share on other sites More sharing options...
Daniel0 Posted April 17, 2007 Share Posted April 17, 2007 Can someone explain this line to me please? $pattern = '/\[quote\].*\[\\\quote]/'; Whats with all the \\\ ? Thanks I think it should have been: $pattern = '/\[quote\].*\[\/quote]/'; Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231581 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 was the first thing i tried it failed!! which is weird on a wim i tryed \\\ and it worked!! EDIT Update got the / around the wrong way on the string corrected <?php $string = 'Hello [quote] how are you [/quote] sorry'; $pattern[] = '/\[quote\].*\[\/quote\]/'; $replacement[] = 'oops'; echo preg_replace($pattern, $replacement, $string); die; ?> D'Oh! Well you learn from your mistakes and well i make loads Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231583 Share on other sites More sharing options...
maxic0 Posted April 17, 2007 Share Posted April 17, 2007 hi jack other peoples posts??! Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231584 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 pulling the questions to your own gain at the expense of the member who started the thread! Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231589 Share on other sites More sharing options...
ramli Posted April 17, 2007 Author Share Posted April 17, 2007 Thanks for all the help (and yeh don't hi jack my post ) Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231594 Share on other sites More sharing options...
maxic0 Posted April 17, 2007 Share Posted April 17, 2007 Well sorry, it was one little question. I think he got the answer he wanted anyway. Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231595 Share on other sites More sharing options...
neylitalo Posted April 17, 2007 Share Posted April 17, 2007 When someone is asking for clarification on something mentioned in a particular thread, it is definitely not hijacking. Don't be ridiculous. You'd prefer that someone start a new thread, ask their question, and then provide a link to the original thread so everybody knows what's going on? It's only hijacking if someone takes a thread and asks a completely irrelevant question. Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231616 Share on other sites More sharing options...
ramli Posted April 17, 2007 Author Share Posted April 17, 2007 i know i was just joking no harm done Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231695 Share on other sites More sharing options...
Barand Posted April 17, 2007 Share Posted April 17, 2007 @ramli, I suspect neylitalo's comment was aimed at MadTechie Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231713 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 Yep, i am wearing my bullseye t-shirt today.. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/#findComment-231716 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.