Php 需要简单的正则表达式建议

Php 需要简单的正则表达式建议,php,regex,Php,Regex,不幸的是,由于糟糕的计划,我需要逐个字段编辑一个巨大的html表单。但由于它只是查找和替换,我认为我可以使过程更快。 所以所有字段大致如下所示: <td align="left" width="30%">Incoming date:</td> <td align="left"> <input name="inc_date" class="frmfixededit" size="20"></td> </tr> .... <

不幸的是,由于糟糕的计划,我需要逐个字段编辑一个巨大的html表单。但由于它只是查找和替换,我认为我可以使过程更快。 所以所有字段大致如下所示:

<td align="left" width="30%">Incoming date:</td>
<td align="left">
<input name="inc_date" class="frmfixededit" size="20"></td>
</tr>
....
<td align="left" width="30%">Name:</td>
<td align="left">
<input name="name" class="frmfixededit" size="20"></td>
</tr>
传入日期:
....
姓名:
我想做的是将其更改为:

<td align="left" width="30%">Incoming date:</td>
<td align="left">
<input name="inc_date" <?php if ($u==TRUE) echo "value='$row['inc_date']'"; ?> class="frmfixededit" size="20"></td>
</tr>
....
<td align="left" width="30%">Name:</td>
<td align="left">
<input name="name" <?php if ($u==TRUE) echo "value='$row['name']'"; ?> class="frmfixededit" size="20"></td>
</tr>
传入日期:
这个怎么样:

$result = preg_replace(
    '/<input name="  # Match start of tag
    ([^"]+)        # Match and capture the name
    "              # Match closing quote
    (.*)           # Match and capture rest of the line/x', 
    '<input name="\1" <?php if ($u==TRUE) echo "value=\'$row[\'\1\']\'"; ?>\2', $subject);
$result=preg\u replace(
“/这个怎么样:

$result = preg_replace(
    '/<input name="  # Match start of tag
    ([^"]+)        # Match and capture the name
    "              # Match closing quote
    (.*)           # Match and capture rest of the line/x', 
    '<input name="\1" <?php if ($u==TRUE) echo "value=\'$row[\'\1\']\'"; ?>\2', $subject);
$result=preg\u replace(

“/在您选择的IDE中执行正则表达式查找并替换为查找模式:

<input name="(.*)" class="(.*)" size="20">

和替换模式:

<input name="$1" <?php if ($u==TRUE) echo "value='$row['$1']'"; ?> class="$2" size="20">

在您选择的IDE中执行Regex Find&Replace with Find模式:

<input name="(.*)" class="(.*)" size="20">

和替换模式:

<input name="$1" <?php if ($u==TRUE) echo "value='$row['$1']'"; ?> class="$2" size="20">

在ide中使用全部查找/替换,或记事本++:>在ide中使用全部查找/替换,或记事本++:>我正在使用aptana,替换失败。但我将下载texmate。我在记事本++上尝试了这一点,效果很好。非常感谢!为我节省了大量时间和工作:)我正在使用aptana,但替换失败。但我将下载texmate。我在记事本++上尝试了这一点,效果很好。非常感谢!为我节省了大量时间和工作:)