Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
-
ykarmi
- Forum Commoner
- Posts: 35
- Joined: Mon Oct 30, 2006 4:45 pm
Post
by ykarmi »
Hey Guys,
Quick question, I'm trying to run the following script on my website
Code: Select all
$content = '<br>hello</br>';
$content = preg_replace('<[^>]+>','<br>',$content);
echo $content;
But I get Warning: Unknown modifier ']' in /usr...
What's going on?
Here's a php info page:
http://www.ykcreations.com/tibiaWars/phpinfo.php
Thanks,
Yuval

-
superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign »
phpinfo() tells us nothing in this case.
What line of code is the warning referring to?
-
Benjamin
- Site Administrator
- Posts: 6935
- Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin »
Code: Select all
$content = preg_replace('#<[^>]+>#','<br>',$content);
-
ykarmi
- Forum Commoner
- Posts: 35
- Joined: Mon Oct 30, 2006 4:45 pm
Post
by ykarmi »
Thank you very much. That completely solved the problem. Does PHP not accept regex inside single quotes?
Thanks!
Yuval
-
superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign »
ykarmi wrote:Thank you very much. That completely solved the problem. Does PHP not accept regex inside single quotes?
Thanks!
Yuval
No, astions pointed out that you forgot your delimiters.