siriussilen
V2EX  ›  问与答

请教一下零宽断言的的多重条件判断问题

  •  
  •   siriussilen · Sep 11, 2019 · 984 views
    This topic created in 2443 days ago, the information mentioned may be changed or developed.

    各位大佬,问题是这样的,目前已知有一行字符串 “I am an -stu- dent”

    我想匹配 I am an dent 由于-不在‘\b’的匹配范围内,因而我想使用零宽断言来解决

    (?<=\s)\w+(?=\s)保证了我能够匹配到 am an 但是对于改行字符串开头和结尾 I 和 dent 则无法匹配,我知道^和$分别表示字符串开头和结尾,但是怎么把这个条件嵌入到零宽断言中呢?

    我试了一下(?<=[\s^])这样的写法是不对的。。

    萌新求指教

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5030 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 09:32 · PVG 17:32 · LAX 02:32 · JFK 05:32
    ♥ Do have faith in what you're doing.