regex greedy match ends with character or end of string

This question already has an answer here:

  • My regex is matching too much. How do I make it stop? 4 answers

  • You could do:

    ^(?P<action>S+) 
    (?P<target_object_label>.+)s
    (?P<object_type>Owner Sharing Rule)s
    (?P<object_label>[^:n]+)               # stop before : or newline
    

    See a demo on regex101.com (mind the different modifiers!).

    链接地址: http://www.djcxy.com/p/76972.html

    上一篇: 有没有可能改变emacs的regexp语法?

    下一篇: 正则表达式贪婪匹配以字符或字符串结尾结束