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 3 of 3
  1. #1
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,007
    Thanks
    59
    Thanked 10 Times in 10 Posts

    Question Advanced dreamweaver regex useage, Pros look here :)

    Huy Guys, I've got a tricky one here! I want all expressions in my code like this

    Code:
    while ($row = mysql_fetch_array($result)) {
                $s = $row["Instruction"];
                $a[$s] = $s;
            }
    to be turned into this

    Code:
        while ($row = mysql_fetch_array($result)) {
                $s = $row["Instruction"];
                $t = $row["InstructionID"];
                $a[$t] = $s;
            }
    can it be done?
    Last edited by nikos101; 04-05-2008 at 10:56 AM.


  • #2
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,007
    Thanks
    59
    Thanked 10 Times in 10 Posts
    the best I can come up with is this

    find
    Code:
    ($s) = $row\["([a-zA-Z]+)"]; 
    $a\[$s] = $s;
    replace
    Code:
    ($s) = $row\["$1"];($t) = $row\["$1ID"];
    $a\[$t] = $s;
    of course it doesn't work yet
    Last edited by nikos101; 04-05-2008 at 11:37 AM.


  • #3
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,007
    Thanks
    59
    Thanked 10 Times in 10 Posts
    I fixed it my expressions are

    find

    \$s = \$row\["(\w+)"];\s+.+;
    which finds

    $s = $row["Instruction"];
    $a[$s] = $s;

    replace

    $s = $row["$1"];\n\t\t\t$t = $row["$1ID"];\n\t\t\t$a[$t] = $s;

    spits out

    $s = $row["Instruction"];
    $t = $row["test"];
    $a[$t] = $s;
    Last edited by nikos101; 04-05-2008 at 02:39 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
    •