【问题标题】:Remove everything before br tag Regex删除 br 标签正则表达式之前的所有内容
【发布时间】:2015-02-07 13:26:20
【问题描述】:

如何删除正则表达式 Yahoo 管道中第一个 br 标记之前的所有内容?

正则表达式模块

in [item.description] replace [.+(<br>)] with [mytext]

【问题讨论】:

    标签: regex yahoo-pipes


    【解决方案1】:

    你的:

    in [item.description] replace [.+(<br>)] with [mytext]
    

    正确:

    in [item.description] replace [.+?(<br>)] with [mytext]
    

    请参阅:Greedy vs. non-greedy matching

    另外,括号是多余的。 .+?&lt;br&gt; 也可以。

    【讨论】:

    • 感谢@tomalak。您提供的参考资料也很有用。如果要替换第二个 br 标记之前的所有内容,正则表达式会是什么?
    • 理论上,replace [.+?&lt;br&gt;.+?&lt;br&gt;] with [nothing](或稍有变化,取决于输入),但正则表达式不是处理 HTML 的正确工具,因此不可能给出明确的答案。只能有适用于某些输入的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-24
    • 2011-05-20
    • 1970-01-01
    相关资源
    最近更新 更多