在stackerflow上有很多问题,他们说字符串是否只包含英文字母。但我想知道如何检查字符串是否有英文字母:
例如:
$string="で書くタッチイベント B A(フ";
if(??? $string)
//this string has some english letters .
使用preg_match()
示例:-
<?php
$subject = "abcdef";
$pattern = '/^def/';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
?>
wrt问题会是这样的:-
<?php
$string = "で書くタッチイベント B A(フ";
$pattern = '/[a-zA-Z]/';
preg_match($pattern, $string, $matches);
print_r($matches);
?>