Some news on PCRE front:

1. I've upgraded the bundled PCRE library to version 4.3 which has some
   interesting new features. 

2. I added new parameter to preg_match* functions that can be used to
   specify the starting offset of the subject string to start matching
   from. The offset can be positive or negative, like for substr().

3. Also implemented support for named subpatterns (introduced with PCRE
   4.3). This means you can do something like:

   <?
   preg_match('!(\d+)(?P<ahh>\.\d+)?!', 'ab 55.5 bb', $match);
   var_dump($match);
   ?>

   With the result being:

    array(4) {
      [0]=>
      string(4) "55.5"
      [1]=>
      string(2) "55"
      ["ahh"]=>
      string(2) ".5"
      [2]=>
      string(2) ".5"
    }

   Note that the named subpattern is also available under a positional
   numeric key, as before. What this means for backwards compatibility
   is that you should not do count($match) anymore to obtain the number
   of captured subpatterns or number of matches. For latter, use the
   return value of preg_match* functions, and for former, you should
   already know how many subpatterns you have from your regexp.

4. You can use \Q..\E to ignore regexp metacharacters in the pattern.
   For example:

    !\w+\Q.$.\E$!

    Will match one or more word characters, followed by literals .$. and
    anchored at the end of the string.

5. You can use possesive quantifiers, similar to Java's regexps. These
   are:

    ?+, *+, ++, and {,}+

   See PCRE docs or Java docs for more information.

6. There is now support for recursive calls to individual subpatterns.
   That is, instead of using (?R) you can use (?1), (?2) and so on. Or
   use named subpatterns: (?P>foo) will refer recursively to named
   subpattern 'foo'. Once again see PCRE docs for more info.

7. There is a new feature by the name of "callouts", but there is not
   interface to it yet. Basically, it allows user to receive control at
   a specified matching point in the pattern and inspect, continue, or
   interrupt the matching. I'm not sure how useful this would be for PHP
   users as the information provided is fairly low-level. See
   'pcrecallout' PCRE man page for more info. If there are enough
   interested people, I will add support for it.

That's about it for now.

-Andrei

"What's a polar bear?"
"A rectangular bear after a coordinate transform."
    -- Bill White ([EMAIL PROTECTED])

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to