match any character except word

This question already has an answer here:

  • Regular expression to match a line that doesn't contain a word? 25 answers
  • Regular Expression block negation 1 answer

  • The linked possible duplicate is about matching a row that does not contain a specified word. I am not sure if it is, what is asked here.

    If you want to match everything in a string but not the specified word you have to use the anchor b word boundary instead of ^ start of a string and $ end of a string.

    For example

    b(?:(?!your).)+b
    

    to match everything except the word "your"

    See it here on Regexr

    (?!your) is a negative lookahead assertion that is true, if the string "your" is not following the current position.

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

    上一篇: 替换文件中的所有链接

    下一篇: 匹配除字之外的任何字符