www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] regexp preg_replace, need help.

Threaded View

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    resolved [RESOLVED] regexp preg_replace, need help.

    Hey!

    I need help making a preg_replace() command to replace some stuff on my webpage.

    I've got a text like this:

    "click !:here:! to get some info about some stuff";

    and another variable, with the URL for a link, that will change often. So I want to use preg_replace to replace the !: and the :! with <a> and </a> tags.

    So I'm thinking something like this

    Code:
    preg_replace("/!:(.*):!/", "<a href='{$URL}'>$text</a>", $infotext);
    so the regexp, I don't really know if that's any good at all. It's just something I think might be correct. The thing is that the link could be anywhere in the string $infotext, and with any chars between the !: and the :!.. possible that I might want to change the symbols !: and :! too. I'm not really good at REGEXP.

    the $text variable shall be taken from the regexp search-pattern. Because the text between !: and :! will change quite often too.

    Hope this is possible.

    Cheers,
    Artheus
    Last edited by artheus; 02-08-2010 at 03:18 AM. Reason: some mistakes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles