Regex - Find all matching words that that don't begin with a specific prefix

前端 未结 4 1010
误落风尘
误落风尘 2020-12-03 08:14

How would I construct a regular expression to find all words that end in a string but don\'t begin with a string?

e.g. Find all words that end in \'friend\' that don

4条回答
  •  悲&欢浪女
    2020-12-03 08:36

    This may work:

    \w*(?

    you could also try

    \w*(? if you wanted to match words like befriended or boyfriends.

    I'm not sure if ? is available in all regex versions, but this expression worked in Expersso (which I believe is .NET).

提交回复
热议问题