Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Last active February 4, 2018 18:58
Show Gist options
  • Save kobus1998/29afda17d0d0393ad2f15ddb8227272c to your computer and use it in GitHub Desktop.
Save kobus1998/29afda17d0d0393ad2f15ddb8227272c to your computer and use it in GitHub Desktop.
function capture
<?php
$regex = "(?<function>(?:int)\s*\w+\s*\((?:(?:int)\s*\w+\s*\,\s*){0,}+(?:int)\s*\w+\s*\)\s*\{\s*.*\s*\})";
$str = "
int count(int i, int a)
{
return i++;
}
";
preg_match("/$regex/", $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
print_r($matches);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment