drdawt9210
2016-03-23 07:50
浏览 38
已采纳

用记事本++一次替换PHP脚本中的一些文本

I need to replace some PHP script with a form like this:

the original text:

mysql_query ("UPDATE table SET fill = '$_POST[aaa]' WHERE id = '1'");
mysql_query ("UPDATE table SET fill = '$_POST[bbb]' WHERE id = '2'");
mysql_query ("UPDATE table SET fill = '$_POST[ccc]' WHERE id = '3'");
mysql_query ("UPDATE table SET fill = '$_POST[ddd]' WHERE id = '4'");
mysql_query ("UPDATE table SET fill = '$_POST[eee]' WHERE id = '5'");

changed to:

mysql_query ("UPDATE table SET fill = '$aaa' WHERE id = '1'");
mysql_query ("UPDATE table SET fill = '$bbb' WHERE id = '2'");
mysql_query ("UPDATE table SET fill = '$ccc' WHERE id = '3'");
mysql_query ("UPDATE table SET fill = '$ddd' WHERE id = '4'");
mysql_query ("UPDATE table SET fill = '$eee' WHERE id = '5'");

how to replace the entire text at once? I use Notepad ++ as my text editor. Thank you very much.

图片转代码服务由CSDN问答提供 功能建议

我需要用以下格式替换某些PHP脚本:

原文:

  mysql_query(“UPDATE table SET fill ='$ _POST [aaa]'WHERE id ='1'”); 
mysql_query(“UPDATE table SET fill  ='$ _POST [bbb]'WHERE id ='2'“); 
mysql_query(”UPDATE table SET fill ='$ _POST [ccc]'WHERE id ='3'“); 
mysql_query(”UPDATE table SET fill“  ='$ _POST [ddd]'WHERE id ='4'“); 
mysql_query(”UPDATE table SET fill ='$ _POST [eee]'WHERE id ='5'“); 
   
 
 

更改为:

  mysql_query(“UPDATE table SET fill ='$ aaa'WHERE id ='1'”); 
mysql_query(  “UPDATE表SET fill ='$ bbb'WHERE id ='2'”); 
mysql_query(“UPDATE table SET fill ='$ ccc'WHERE id ='3'”); 
mysql_query(“UPDATE table SET fill =  '$ ddd'WHERE id ='4'“); 
mysql_query(”UPDATE table SET fill ='$ eee'WHERE id ='5'“); 
   
 
 <  p>如何立即替换整个文本? 我使用Notepad ++作为我的文本编辑器。 非常感谢你。 
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doushuo1080 2016-03-23 07:55
    已采纳

    You can use it's regular expression Find-Replace features... A pattern like so

    \_POST\[(.*)\]
    

    (add global match modifier like /g if need)

    and replacing it with only

    $1
    

    will work. here https://regex101.com/r/vC8tW7/1 a working demo.

    点赞 打赏 评论

相关推荐 更多相似问题