Re: [pcre] backreferences to all matches of a repeated subexpression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 01, 2007 at 08:05:09PM -0700, Jack Bates wrote:
> I'm not sure how to get an array of all subexpression matches, in the
> order matches appear in the subject, instead of the order expressions
> appear in the pattern.

This problem gave me a headache. My only idea is to use preg_split()
instead.

  <?php
  $foo = preg_split('/\[(.*)\]+|\./U',
         "foo.bar[ab.cd].baz",
         -1,
         PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);

  var_dump($foo);
  ?>

Seems to work as intended. Hope I could help.

Regards
  Steffen

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux