General Community > Scripting Help
regexp for striping tags
(1/1)
fractalbit:
Hi, can anyone write for me a regular expression in php that cuts the ubbc tags? For example we have the text :
--- Code: ---This is [b]a test text[/b]
--- End code ---
After running the expression we should get :
This is a test text
I tried this :
--- Code: ---txt = ereg_replace("\[(.*)\]","", $txt);
--- End code ---
But it returns this :
This is
So i know it is wrong but i dont know how to fix it. Please help.
Spaceman-Spiff:
easy/lazy way: parse it using DoUBBC, then use strip_tags :P
i'm not good at regex, better wait for someone else....
Aquilo:
I don't know if this is a good why to do it but here is my shoot! it works...
<?php
$txt = 'This is a test text';
$txt = ereg_replace("[\[|\[\/]+[a-zA-Z]+\]", "", $txt);
echo $txt;
?>
Aquilo
fractalbit:
--- Quote from: Spaceman-Spiff on October 03, 2003, 07:34:46 PM ---easy/lazy way: parse it using DoUBBC, then use strip_tags :P
i'm not good at regex, better wait for someone else....
--- End quote ---
That actually is an excellent idea that will work for sure! I also thank the other person that replied but i will probably go with the lazy solution :D
Navigation
[0] Message Index
Go to full version