added null check along with empty string check

Hi Leonardo,

I took update which had my last checkins and with that my old jobs started failing.
I found out bug in my code where I had checked input strings for empty but missed to check for null.
Have added null check and tested with both old jobs where I don't specify regex and new one with regex.
Kindly check.