In the book of D. Koterov there is a chapter "pockets of regulars", but little understand what it is. Maybe a mini lecture someone will hold or links, or books, where it is described.

Maybe it has a different name?

1 answer 1

In short:

preg_match('/([abc]+)([0-9]+)(?:[a-z0-9]+)/',,); 

Almost everything between // enclosed in parentheses will be stored in special temporary variables. The strange name "pockets" I hear for the first time, but oh well. /..../ corresponds to zero pocket. That is, everything that coincides with the full expression falls into the $ 0 variable. ([abc] +) is the first pocket. ([0-9] +) - the second. (?: [a-z0-9] +) - none at all, since the word?: says that this grouping should not be remembered.

To understand this in more detail, make a complex regular schedule, make a preg_match_all for a long text, and then print the result using print_r .

  • thanks for the reference - zloctb
  • one
    The link no longer works. - ReinRaus
  • Removed the exile altogether. It is still lying on the web archive, but no one will climb there. Thank. - knes