S75 Posted June 18, 2013 Share Posted June 18, 2013 Hi, i'm having this error on my page, but i cant get it solved. Can some please help me ? I am searching for almost 2 weeks now. Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /home/simonky109/domains/gunstreet.nl/public_html/ubb.php on line 46 Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /home/simonky109/domains/gunstreet.nl/public_html/ubb.php on line 47 This is what the lines says : $bericht = preg_replace('/\*)]([^[]*)\[\/email]', '<a href="mailto:[email protected]">2</a>', $bericht); $bericht = preg_replace("/\*)\]([^[]*)\[\/url\]", "<a href='1' target='_blank'/>\\2</a>", $bericht); Thank you for your help. Greetings Simone. Link to comment https://forums.phpfreaks.com/topic/279327-please-help-error-preg_replace/ Share on other sites More sharing options...
requinix Posted June 18, 2013 Share Posted June 18, 2013 You're missing the ending / delimiters. [edit] Which is exactly what the error message says. Weird, huh? Link to comment https://forums.phpfreaks.com/topic/279327-please-help-error-preg_replace/#findComment-1436719 Share on other sites More sharing options...
Psycho Posted June 18, 2013 Share Posted June 18, 2013 The error is exactly as it says - you are missing the ending delimiter. When defining your regular expression it needs to be enclosed within delimiters (in addition to the quote marks). This is because a regular expression can have additional parameters that are not part of the matching expression. You start your regular expression with a / so, it must have a closing / as well. I typically use # instead of the slashes because those are more often used in the matching characters. So, here are your expressions corrected: $bericht = preg_replace('/\[email=([^[]*)]([^[]*)\[\/email]/', '<a href="mailto:[email protected]">2</a>', $bericht); $bericht = preg_replace("/\[url=([^[]*)\]([^[]*)\[\/url\]/", "<a href='1' target='_blank'/>\\2</a>", $bericht); But, you probably didn't realize those expressions won't work if the BB code had uppercase characters. That is one of the reasons you would add an additional parameter after the last delimiter. In this case you would add the parameter 'i' to be case insensitive. Here are the expressions adding case insensitivity AND fixing the dynamic replacements. $bericht = preg_replace('#\[email=([^]]*)\]([^[]*)\[\/email\]#i', '<a href="mailto:\\1">\\2</a>', $bericht); $bericht = preg_replace('#\[url=([^]]*)\]([^[]*)\[\/url\]#i', '<a href="\\1" target="_blank">\\2</a>', $bericht); Link to comment https://forums.phpfreaks.com/topic/279327-please-help-error-preg_replace/#findComment-1436720 Share on other sites More sharing options...
S75 Posted June 18, 2013 Author Share Posted June 18, 2013 i dont get it i'm just a beginner in php. Must i put the / after the word "bericht" ? sorry but i really dont understand what you mean and sorry for my bad english i come from the netherlands. Link to comment https://forums.phpfreaks.com/topic/279327-please-help-error-preg_replace/#findComment-1436725 Share on other sites More sharing options...
Psycho Posted June 18, 2013 Share Posted June 18, 2013 preg_replace('#\]*)\]([^[]*)\[\/email\]#i', '<a href="mailto:\\1">\\2</a>', $bericht); The two # in red are the beginning and ending delimiters for the matching part of the regular expression above. The part in bllue is the matching part of the expression and the green "i" at the end is a parameter to make the expression case insensitive (i.e. "word" = "WoRd"). Your original code had a / for the beginning delimiter, but there was no corresponding / for the end of the matching part of the expression. There were /'s in the expression but they were not the ending delimiter. I used # because it is not used in the matching expression and is more obvious. Link to comment https://forums.phpfreaks.com/topic/279327-please-help-error-preg_replace/#findComment-1436729 Share on other sites More sharing options...
S75 Posted June 18, 2013 Author Share Posted June 18, 2013 Thank you verry much the problem is solved now Now i'm going to look for the last error permission denied in : $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); Thanks again !! Link to comment https://forums.phpfreaks.com/topic/279327-please-help-error-preg_replace/#findComment-1436731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.