homepage Welcome to WebmasterWorld Guest from 54.166.53.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
preg_replace Error
Unknown modifier
Knowles

10+ Year Member



 
Msg#: 1130 posted 2:37 pm on Oct 2, 2002 (gmt 0)

Ok I am doing some ubb code for a forum I am getting this error:
Warning: Unknown modifier '/' in file.php on line 142

Line 142 is:
$msg = preg_replace("/[url](http://)?(.*?)[/url]/si", "<a href='12' target='_blank'>2</a>", $msg);

Any ideas what this means?

 

Knowles

10+ Year Member



 
Msg#: 1130 posted 3:33 pm on Oct 2, 2002 (gmt 0)

Ok I fixed the warning error by changing the line to this:
$msg = preg_replace("#/[url](http://)?(.*?)[/url]/si#", "<a href='12' target='_blank'>2</a>", $msg);

But now its not replacing it like it should. Any ideas?

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1130 posted 3:38 pm on Oct 2, 2002 (gmt 0)

You are using the slash as the delimiter for your regex. The engine will look for the first slash to end the expression.

Either choose a delimter that is not contained within your expression or escape the slashes.

Andreas

Knowles

10+ Year Member



 
Msg#: 1130 posted 3:51 pm on Oct 2, 2002 (gmt 0)

Thanks andreasfriedrich I just figured that out now to tackle the next issue. Thanks again for the help.

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1130 posted 2:07 am on Oct 3, 2002 (gmt 0)

Perhaps you would like to post an example of a string you want to perform the replacement on? That would be helpful to test your expression.

BTW I didnīt see that you already solved the first problem when I posted my reply and was just too lazy to edit it.

Andreas

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved