Warning: Unknown modifier ']' in /usr...

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Warning: Unknown modifier ']' in /usr...

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 :D
User avatar
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?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Warning: Unknown modifier ']' in /usr...

Post by Benjamin »

Code: Select all

$content = preg_replace('#<[^>]+>#','<br>',$content);
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Thank you!

Post by ykarmi »

Thank you very much. That completely solved the problem. Does PHP not accept regex inside single quotes?
Thanks!
Yuval
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Thank you!

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.
Post Reply