Regex to match string not ending with pattern

后端 未结 4 1518
北恋
北恋 2020-12-06 11:07

I try to find a regex that matches the string only if the string does not end with at least three \'0\' or more. Intuitively, I tried:

.*[^0]{3,}$

4条回答
  •  伪装坚强ぢ
    2020-12-06 11:46

    You can try using a negative look-behind, i.e.:

    (?

    Tests:

    Test  Target String   Matches
    1     654153640       Yes
    2     5646549800      Yes   
    3     848461158000    No
    4     84681840000     No
    5     35450008748     Yes   
    

    Please keep in mind that negative look-behinds aren't supported in every language, however.

提交回复
热议问题