Need a regex to exclude certain strings

后端 未结 6 1430
无人及你
无人及你 2021-01-02 15:18

I\'m trying to get a regex that will match:

somefile_1.txt
somefile_2.txt
somefile_{anything}.txt

but not match:

somefile_1         


        
6条回答
  •  旧巷少年郎
    2021-01-02 15:45

    somefile_(?!16).*\.txt
    

    (?!16) means: Assert that it is impossible to match the regex "16" starting at that position.

提交回复
热议问题