I'm trying to parse PHPDoc tags with preg_match, but I'm having some issue with negative lookbehind. I've never used those before, but it is my understanding that they're used as exclusions.
Here is my pattern:
/\*\*.+?(?<! \*/)@access public.+? \*/\s+?function\s+[a-zA-Z0-9_]+\(
Here is my sample PHP file I'm trying to parse:
<?php
/**
* This is the shortcut to DIRECTORY_SEPARATOR
*/
defined('DS') or define('DS',DIRECTORY_SEPARATOR);
/**
* Foo
*
* @return bool
* @access public
*/
function foo()
{
return true;
}
I want to match any function with an @access public tag, but in this case the match starts at the DS constant's comment. I thought the (?<! \*/)
would exclude it matching the closing comment tag of the DS comment.
What am I missing?