Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created February 3, 2012 10:03
Show Gist options
  • Save radmiraal/1729464 to your computer and use it in GitHub Desktop.
Save radmiraal/1729464 to your computer and use it in GitHub Desktop.
Regexp
class test {
protected $methodRegex = <<<EOF
/^
\s*
(?P<visibility>public|protected|private)?
\s*
function
\s*
(?P<methodName>\w*)
\s*\(
/
EOF;
public function getMethodRegex() {
return preg_replace("/(\n|\t|\r)/", NULL, $this->methodRegex);
}
}
@radmiraal
Copy link
Author

public $methodRegex = <<<EOF
/^
    \s*
    (
        (?P<visibility>public|protected|private)?
        |
        (?P<static>static)?
    ){1,2}
    \s*
    function
    \s*
    (?P<methodName>\w*)
    \s*\(
/

EOF;

@radmiraal
Copy link
Author

public $methodRegex = <<<EOF
/^
    \s*
    (
        ((?P<visibility>public|protected|private)\s*)
        |
        ((?P<static>static)\s*)
    ){0,2}
    \s*
    function
    \s*
    (?P<methodName>\w*)
    \s*\(
/

EOF;

@radmiraal
Copy link
Author

public $methodRegex = <<<EOF
/^
    \s*                                                         # Some possible whitespace
    (
        ((?P<visibility>public|protected|private)\s*)           # Visibility declaration
        |
        ((?P<static>static)\s*)                                 # Static declaration
    ){0,2}                                                      # Visiblity and Static can both occur, in any order
    \s*                                                         # Some possible whitespace
    function                                                    # Literal string 'function'
    \s*                                                         # Some possible whitespace
    (?P<methodName>\w*)                                         # The method name
    \s*\(                                                       # Some possible whitespace followed by a (
/x

EOF;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment