【问题标题】:How to exclude a charachter in sublime text regex match and replace如何在崇高文本正则表达式匹配和替换中排除字符
【发布时间】:2014-04-11 17:44:35
【问题描述】:

我尝试使用 ST 正则表达式替换以下内容:

echo Street = $this->input->post('Street');
echo City= $this->input->post('City');

我想把每一行变成:

echo City= trim($this->input->post('City'));

我使用的正则表达式是:

\$this(.+);

但这匹配整行,包括最后的';'

我怎样才能只选择:

$this->input->post('City')

【问题讨论】:

    标签: regex sublimetext2 sublimetext3


    【解决方案1】:

    试试这个:

    \$this([^;]+)
    

    [^;] 表示除分号之外的任何内容:-)

    【讨论】:

      【解决方案2】:

      也许这就是你想要的

      \$this([^;]+)
      

      【讨论】:

        【解决方案3】:

        =\s\$this(.+\') 应该管用。我不确定 sublime texts RE 引擎的细节。

        【讨论】:

        • 感谢您的意见
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-31
        相关资源
        最近更新 更多