Archived Boards and Threads... > Parham's PHP Tutorials

PHP Lesson 17 - Regular Expressions

<< < (4/4)

Parham:
my mistake, sorry.

Saleh:

--- Quote ---Pattern: ab?c
Matches: 'ac', 'abc'
Explanation: match "a" followed by "b" optionally and then "c"
--- End quote ---
I think you mean it matches 'ab', 'abc' not 'ac'!! right?

Parham:

--- Quote from: NeverMind on May 27, 2004, 05:59:18 AM ---
--- Quote ---Pattern: ab?c
Matches: 'ac', 'abc'
Explanation: match "a" followed by "b" optionally and then "c"
--- End quote ---
I think you mean it matches 'ab', 'abc' not 'ac'!! right?

--- End quote ---

nope, the "?" is on the "b"... the "b" is therefore optional.  try it in a script, you'll see that "ab" will not match.

[Unknown]:
To clarify:

[a]?[c]

Means:

[a] and then maybe and then [c].

-[Unknown]

Navigation

[0] Message Index

[*] Previous page

Go to full version