regular expression for anything but an empty string

前端 未结 9 1028
予麋鹿
予麋鹿 2020-11-29 01:22

Is it possible to use a regular expression to detect anything that is NOT an \"empty string\" like this:

string s1 = \"\";
string s2 = \" \";
string s3 = \"          


        
9条回答
  •  忘掉有多难
    2020-11-29 01:56

    What about?

    /.*\S.*/
    

    This means

    / = delimiter
    .* = zero or more of anything but newline
    \S = anything except a whitespace (newline, tab, space)

    so you get
    match anything but newline + something not whitespace + anything but newline

提交回复
热议问题