【问题标题】:Regular expression - starting and ending with a specific string正则表达式 - 以特定字符串开头和结尾
【发布时间】:2017-09-17 17:52:54
【问题描述】:

我们有很多配置文件,我正在尝试使用 RegEx 查找特定的开始行尾

set ftp {any text here} disabled=yes

样本:

set ftp disabled=yes

set ftp address=10.0.0.0/24,10.1.1.0/24 disabled=yes

set ftp address=10.0.0.1,10.1.1.1,10.1.2.2 disabled=yes

set ftp address=10.95.140.0/24,10.94.140.0/24 disabled=yes

【问题讨论】:

  • 哪种编程语言?
  • 澄清您的具体问题或添加其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。请参阅How to Ask 页面以帮助澄清此问题

标签: regex


【解决方案1】:
/set ftp.*disabled=yes/

您可能会发现使用诸如refiddle.com 之类的网站来测试您的正则表达式很有帮助。

【讨论】:

  • 非常感谢,我花了将近 5-6 个小时试图弄清楚这一点 - 只是向知道自己在做什么的人展示它是多么简单:)
【解决方案2】:

你可以使用:

/set ftp \S+ disabled=yes/

demo & explanation

【讨论】:

    猜你喜欢
    • 2013-08-04
    • 1970-01-01
    • 2023-01-02
    • 2015-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    相关资源
    最近更新 更多