Regular expression: Difference between revisions

Jump to navigation Jump to search
Line 484: Line 484:
<pre>
<pre>
if (preg_match('/[^\x20-\x7f]/', $keyword) === 0) {
if (preg_match('/[^\x20-\x7f]/', $keyword) === 0) {
  echo "The keyword is ASCII only";
    echo "The keyword is ASCII only";
} else {
    echo "The keyword contains non-ASCII characters (like Chinese, Japanese, etc.)";
}
}
</pre>
</pre>

Navigation menu