<?php
// NOTE: array of sample input strings to demonstrate
'my_fiancée' , // match expected
'über' , // match expected
'my_bloody_valentine' , // match expected
'"ABC, Easy as 123!"' , // match expected
'whocares@whocares.com' , // match NOT expected
"'foo'" , // match expected
'bar?' ) ; // match NOT expected
foreach ( $inputs as $input ) {
if ( ! preg_match ( "/^[\pL0-9_.,!\" ' ]+$/u" , $input ) ) { // ^
echo "\" $input \" => error\r \n " ; // FORNOW: to explicitly note non-matches
//echo 'error';
} else { // FORNOW: else to explicitly indicate matches
echo "\" $input \" => all good\r \n " ;
}
}
?>
PD9waHAKCi8vIE5PVEU6IGFycmF5IG9mIHNhbXBsZSBpbnB1dCBzdHJpbmdzIHRvIGRlbW9uc3RyYXRlCiRpbnB1dHMgPSBhcnJheSgKCSdteV9maWFuY8OpZScsICAgICAgICAgICAgLy8gbWF0Y2ggZXhwZWN0ZWQKCSfDvGJlcicsICAgICAgICAgICAgICAgICAgLy8gbWF0Y2ggZXhwZWN0ZWQKCSdteV9ibG9vZHlfdmFsZW50aW5lJywgICAvLyBtYXRjaCBleHBlY3RlZAoJJyJBQkMsIEVhc3kgYXMgMTIzISInLCAgIC8vIG1hdGNoIGV4cGVjdGVkCgknd2hvY2FyZXNAd2hvY2FyZXMuY29tJywgLy8gbWF0Y2ggTk9UIGV4cGVjdGVkCgkiJ2ZvbyciLCAgICAgICAgICAgICAgICAgLy8gbWF0Y2ggZXhwZWN0ZWQKCSdiYXI/Jyk7ICAgICAgICAgICAgICAgICAvLyBtYXRjaCBOT1QgZXhwZWN0ZWQKCmZvcmVhY2goJGlucHV0cyBhcyAkaW5wdXQpIHsKCWlmICghcHJlZ19tYXRjaCgiL15bXHBMMC05Xy4sIVwiJyBdKyQvdSIsICRpbnB1dCkpIHsKICAgICAgICAvLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXgoJCWVjaG8gIlwiJGlucHV0XCIgPT4gZXJyb3JcclxuIjsgLy8gRk9STk9XOiB0byBleHBsaWNpdGx5IG5vdGUgbm9uLW1hdGNoZXMKCQkvL2VjaG8gJ2Vycm9yJzsKICAgIH0gZWxzZSB7IC8vIEZPUk5PVzogZWxzZSB0byBleHBsaWNpdGx5IGluZGljYXRlIG1hdGNoZXMKICAgIAllY2hvICJcIiRpbnB1dFwiID0+IGFsbCBnb29kXHJcbiI7CiAgICB9Cn0KCj8+