What is a regex to match ONLY an empty string?

后端 未结 10 1677
忘掉有多难
忘掉有多难 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:06

    Try looking here: https://docs.python.org/2/library/re.html

    I ran into the same problem you had though. I could only build a regex that would match only the empty string and also "\n". Try trimming/replacing the newline characters in the string with another character first.

    I was using http://pythex.org/ and trying weird regexes like these:

    ()

    (?:)

    ^$

    ^(?:^\n){0}$

    and so on.

提交回复
热议问题