代码之家  ›  专栏  ›  技术社区  ›  Gandalf StormCrow

如何匹配前面有其他文本的文本

  •  0
  • Gandalf StormCrow  · 技术社区  · 16 年前

    我怎样才能匹配“ Because it already exists

    <faultstring>Error has occured! Reason why: Because it already exists. request id: 443p3-34356a</faultstring>
    

    此表达式失败:

    (.+)+Because it already exists(.+)+ 
    

    我需要匹配 <faultstring></faultstring> 也是,所以我需要匹配 因为它已经存在了 内部水龙头开启和关闭标签

    注:

    这是一个多行字符串,我刚打印出来这一个很重要。

    4 回复  |  直到 16 年前
        1
  •  1
  •   Toto    16 年前

    更简单地说:

    /Because it already exists/
    
        2
  •  4
  •   Borealid    16 年前

    我认为你不想要那些外在的优点。

    (.+)Because it already exists(.+)
    
        3
  •  1
  •   Community Mohan Dere    9 年前

    使用 this online regular expression tester ,我发现了 Borealid 回复完全满足你的需要。

        4
  •  0
  •   Sylverdrag    16 年前

    这将满足您的要求:

    (?<=.+)Because it already exists(?=.+)
    

    然而,看起来你正在做一些不寻常的事情,可能有更好的方法去做。