...

View Full Version : Advanced dreamweaver regex useage, Pros look here :)



nikos101
04-05-2008, 10:47 AM
Huy Guys, I've got a tricky one here! I want all expressions in my code like this


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


while ($row = mysql_fetch_array($result)) {
$s = $row["Instruction"];
$t = $row["InstructionID"];
$a[$t] = $s;
}can it be done?

nikos101
04-05-2008, 11:34 AM
the best I can come up with is this

find

($s) = $row\["([a-zA-Z]+)"];
$a\[$s] = $s;

replace
($s) = $row\["$1"];($t) = $row\["$1ID"];
$a\[$t] = $s;of course it doesn't work yet

nikos101
04-05-2008, 02:33 PM
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;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum