Jump to content

Please help error preg_replace !


S75

Recommended Posts

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 :
 

 

Link to comment
Share on other sites

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:info@gunstreet.nl">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);
Edited by Psycho
Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.