Jump to content

Recommended Posts

I had this code but now I need to change it to newer preg_replace function

Can someone help me to do it please?

 

Here is the code:

 

    $newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/261660-ereg_replace-to-preg_replace/
Share on other sites

I know that I need to put delimiters, but it is to complicated for me :(

 

If you know where to put them, please help out.

Did you read the link?

it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.

yes I did, but not sure if I need to do this just for first parameter.

I did this and please tell me if it's ok now:

 

$newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);

$newString = preg_replace("#[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]#","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);

Ok, I don't know why are you like that.

 

You could just say: you need to put it here and here

and one line explanation and this will be over in one post

If I knew all of this, I wouldn't post here.

 

Sorry if I am stupid for you guys.

And you could have just read the documentation.  It's there for many reasons, one of them being to prevent posts like this.

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.