【问题标题】:What is the best tool to replace certain parts of a string?替换字符串某些部分的最佳工具是什么?
【发布时间】:2013-10-03 08:51:01
【问题描述】:

我有一些 html 文件要重新构建,如下所示:

转换这个:

<code>echo "hello world";</code>

到这里:

[php]echo "hello world";[/php]

我知道我可以用记事本查找/替换,但我想使用一个工具(最好是在线工具),通过选择 x1,x2,y1,y2 参数,我可以将 x1-abc-y1 转换为 x2-abc-y2

你知道这个功能吗?

感谢您的帮助!

【问题讨论】:

    标签: regex string replace full-text-search str-replace


    【解决方案1】:

    sed 是完成这项工作的工具!

    $ echo "<code>echo "hello world";</code>" | sed 's/<\(\/\?\)code>/[\1php]/g'
    [php]echo hello world;[/php]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-31
      • 2018-04-08
      • 1970-01-01
      • 2018-07-14
      • 2017-08-30
      • 2017-08-30
      • 2013-12-20
      • 2014-03-27
      相关资源
      最近更新 更多