2015-08-27 08:35



Below are the regex for filtering out all the non go files (i.e those with '.go' extension)



You can test them here (click on try it 'Go' in the menu below the regex)

While they seem to work correctly in go but not with inotifywait's exclude filter (which uses posix ERE format)

I am trying to setup a "watch and reload" task in my Makefile for a golang project. Also i am assuming file or folders names dont have spaces.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • doumao8355 doumao8355 6年前

    You may use


    See demo

    Or if you can group:


    See demo

    See explanation:

    • \. - a literal dot
    • ([^.][^.][^.]+|[^.][^o]|[^g][^.]|[^.]) - a group of alternatives:
      • [^.][^.][^.]+ - 2 characters other than . and 1 or more characters other than ....
      • [^.][^o] - a character other than a dot and a character other than o...
      • [^g][^.] - a character other than g and a character other than a dot...
      • [^.] - a character other than a dot...
    • $ - right before the end of string.
    点赞 评论 复制链接分享
  • dp6319 dp6319 6年前

    Got the issue. It seems [:graph:] not \S the class identifier for non-space chars in extended posix. The below is good to go.


    or even a better one from stribizhev comment [^.][^g][^o]$|^..$|.[^g].$|..[^o]$|[^.]..$

    点赞 评论 复制链接分享