What is a regex to match ONLY an empty string?

后端 未结 10 1672
忘掉有多难
忘掉有多难 2020-12-01 13:24

There are lots of posts about regexs to match a potentially empty string, but I couldn\'t readily find any which provided a regex which only matched an emp

10条回答
  •  情话喂你
    2020-12-01 14:15

    As @Bohemian and @mbomb007 mentioned before, this works AND has the additional advantage of being more readable:

    console.log(/^(?!.)/s.test("")); //true

提交回复
热议问题