Jump to content

[SOLVED] Removing sertan text


ramli

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/47457-solved-removing-sertan-text/
Share on other sites

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

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 ;D

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.