"*"または "?"の使用に違いはありますか? PHPのpreg_match?または例がありますか? *
と?
試合が固定されていないので、あなたは違いを見分けることができないあなたの特定のテストの文脈では"*"と "?"の違いは何ですか? PHP pregの試合で?
<?php
// the string to match against
$string = 'The cat sat on the matthew';
// matches the letter "a" followed by zero or more "t" characters
echo preg_match("/at*/", $string);
// matches the letter "a" followed by a "t" character that may or may not be present
echo preg_match("/at?/", $string);
コメントであなたのコードはすでに違いを記述しています。 –
@GregHewgill preg_matchでは、関数は最初の一致の後に停止するので、両方ともですか? *は最初の一致の後で正確に同じポイントで停止し、 "1"を返します。違いはなんですか ? – motto
@GregHewgillのようなものですが、なぜなら、この場合、2つが同じように動作する理由を説明していないことを除いて。 – Alnitak