I want to find the shortest possible regular expression pattern to match an empty string(no whitespacer or anything at all)
I have found
/(\d|)/ (7chars)
and '^[\s]*$' (9 chars)
till now.
Technically /(\d|)/
is 5 characters, the slashes are just delimiters.
The shortest regex I know of that would match an empty string is ^$
.
Why do you need a regex if you can use empty() ? i.e.:
$emptyStr = "";
if(empty($emptyStr)){
echo "I'm empty";
}
you guessed, it outputs "I'm empty".