Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts

    [Regex] Keyword to URL Link

    Hey, everyone. Long time no see, again, huh?

    Well I'm back! Somewhat.

    I'm looking for some help on regex, I have no idea what I'm doing when it comes to this. My ADHD/ADD (Or whatever I might have) and Dyslexia really gets at me.

    Anyways, I'm basically just trying to grab one word that looks like a function, eg:
    Code:
    functionName() [Not-Case Sensitive]
    But I can't quite get it to work. Everything likes to grab more then just one word/function. Lol.

    Here is my code.

    PHP Code:
    <?php

    $message_text 
    'Hello world, this is the nl2br() function.';

    $message_text eregi_replace('/\s\w(.*)\(\(.*)\)/i''<a href="http://php.net/$1" title="$1() Reference">$1()</a>'$message_text);

    echo 
    $message_text;

    ?>
    Last edited by Element; 08-31-2007 at 11:06 PM. Reason: Updated still broken code....

  • #2
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    No help on this? I thought it might be really hard. Drat.

  • #3
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    PHP Code:
    <?php

    $message_text 
    'Hello world, this is the nl2br() function.';

    $message_text preg_replace('/\s([a-zA-Z0-9_]+?)\((.*?)\)/i'' <a href="http://php.net/$1" title="$1() Reference">$1()</a> '$message_text);

    echo 
    $message_text;

    ?>

  • Users who have thanked Mwnciau for this post:

    Element (09-01-2007)

  • #4
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Thank you so much Mwnciau! Your the best! I can't even begin to tell you how much this helps!

    John, our Webmaster says thank you as well, very much.

    See it in action soon on http://pznetworks.com/forums/ !
    Last edited by Element; 09-01-2007 at 07:10 PM.


  •  

    Posting Permissions

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