Jump to content

paj7499

New Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

paj7499's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi I am still confused $subject = "This sentence contain several 'azzz' words"; $pattern = "/az{2}/"; if (preg_match($pattern, $subject)) { echo 'Regular expression <b>found!</b>'; } else { echo 'Regular expression <b>not</b> found!'; } the above code is returning true! ('Regular expression found!) Shouldn't preg_match return false. My understanding is that pattern = "/az{2}/" means match an a followed by exactly zz (2 z's not 3). am i wrong?
  2. Hi I am trying to learn regular expression and am getting some unexpected results! $sentence = "This sentence contains several zzz "; if(preg_match("/z{1}/",$sentence)) { echo "Regular expression found!"; } else { echo "Regular expression NOT found!"; } The above code is echoing out “Regular expression found. I am confused. Shouldn't “/z{1}/” return true only if there is only one z in the string not zzz. What am I missing?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.