[PHP] mb_ereg_match()は部分一致検索してくれないのね……


http://www.php.net/manual/ja/function.mb-ereg-match.php#86429

ユーザー投稿に書いてありますね。これをよく見なかったがために、数字一文字ひっかけるのにえらい苦労してしまいましたとさ(;ω;`)

以下、上記URLからの引用。

Note that this function matches a string from the beginning only (though not necessarily till the end):

<?php

$test = mb_ereg_match(“a”, “some apples”); // returns false
$test = mb_ereg_match(“a”, “a kiwi”);      // returns true

?>

If you want to check for a match anywhere in the string, use the wild-card & repeat operators .*

<?php

$test = mb_ereg_match(“.*a”, “some apples”); // returns true

?>

「この関数は前方一致しかしてくれないから、部分一致検索をしたいときは “.*” を使ってね!」 ということが書いてあると思います。多分。(しっかり読めてません)

まぁどうして引っかからないのか分かってよかったよかった(*´ω`)

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です