Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
最初の文字が文字かどうかを確認するために、この関数を作成しました。
function isLetter($string) { return preg_match('/^\s*[a-z,A-Z]/', $string) > 0; }
ただし、coma () で始まる文をチェックすると,、関数は を返しますtrue。最初の文字が az か AZ かどうかを確認するための適切な正規表現は何ですか?
,
true
コンマを削除するだけです:
'/^\s*[a-zA-Z]/'
私の意見では、少しきれいな方法です。コードをもう少し人間が読めるようにするだけです。
function isLetter($string) { return preg_match('/^[a-z]/i', trim($string)); }