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 5 of 5

Thread: php 'n' reg exp

  1. #1
    New to the CF scene
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php 'n' reg exp

    Hey, I've been looking at reg exp for a while now...ok....a few days...and i can't be the only one who thinks it looks like a tin of spaghetti.

    Say I have an anchor tag:

    <a href="dynamic.php?page=mytest">My Test</a>

    How can I use reg exp to change that anchor tag to:

    <a href="mytest.html">My Test</a>

    I hope someone can help


    Scorpion

    ------------------------------------
    Act first - ask questions later
    ------------------------------------

  • #2
    Registered User
    Join Date
    Feb 2003
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dunno exactly what you want,

    but does the user click on the link? or is that link a string?

    Jesh

  • #3
    New Coder
    Join Date
    Feb 2003
    Location
    Rannana,(o) IsraeL (o)
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: php 'n' reg exp

    Originally posted by scorpion
    <a href="dynamic.php?page=mytest">My Test</a>
    How can I use reg exp to change that anchor tag to:
    <a href="mytest.html">My Test</a>
    I didn't try this code,but it will give you a hint
    Code:
    function myget($str) {
    $temp = preg_replace("/(>(.+)<)/iU",\\2,$str);
    $str = preg_replace("/(\"(.+)page=(.+)\")/iU",\\3,$str);
    $str .= .html;
    return("<a href=\"$str\">$temp</a>");
    }
    I really hope it's working :\

  • #4
    New to the CF scene
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    nearly?

    Hey,

    thanks, that nearly works (I think), but it get an illegal character error. Can you recommend any good books on php reg exp?


    Scorpion

    ------------------------------------
    Act first - ask questions later
    ------------------------------------

  • #5
    New to the CF scene
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ?

    Anyone?



    Scorpion

    ------------------------------------
    Act first - ask questions later
    ------------------------------------


  •  

    Posting Permissions

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