JS代码
¶
console.log('one two three'.match( /e two/ )[0]);
console.log('one two three'.match( /e +two/ )[0]);
console.log('one two three'.match( /e\stwo/ )[0]);
console.log('one two three'.match( /e\s+two/ )[0]);
var tab符 = String.fromCharCode(9);
console.log(('one xxx two' + tab符 + 'three').match( /two\s+thr/ )[0]);
PHP代码 ¶
preg_match('#e two#', 'one two three', $matchResult1);
preg_match('#e +two#', 'one two three', $matchResult2);
preg_match('#e\s+two#', 'one two three', $matchResult3);
preg_match('#e\s+two#', 'one two three', $matchResult4);
$tab符 = chr(9);
preg_match('#two\s+thr#', 'one xxx two' . $tab符 . 'three', $matchResult5);
header('Content-type:text/plain');
print_r([
$matchResult1[0],
$matchResult2[0],
$matchResult3[0],
$matchResult4[0],
$matchResult5[0],