I am using php version 7.0.14. In spite of several good examples on stackoverflow, I cannot get my php regex to work. I've been trying for hours every conceivable combination. The problem comes in trying to allow periods and slashes, which must be escaped. I have tried enclosing the regex in double and single quotes. I have tried escaping with one backslash, two, three, four. It either errors out, lets everything through (like $) or does not allow periods and slashes.
$strStreet = "123 1/2 S. Main St. Apt. 1";
#$strRegEx = "/^[a-z0-9 ,#-'\/]{3,50}$/i";
$strRegEx = '/^[a-z0-9 ,#-\'\/]{3,50}$/i';
if (preg_match($strRegEx, $strStreet) === 0 ) {
print "bad address";
}
Thanks in advance for any help.