Skip to content

Instantly share code, notes, and snippets.

@michaelcontento
Created June 9, 2011 09:38
Show Gist options
  • Save michaelcontento/1016425 to your computer and use it in GitHub Desktop.
Save michaelcontento/1016425 to your computer and use it in GitHub Desktop.
Simple regex for @joemanaco
<?php
$input = <<<EOF
### Section: Imports ###
text....
foo
### End Section ###
EOF;
preg_match(
'/###\s*Section:\s*(?P<section>[^\s]+)\s*###(?P<body>.*)###\s*End Section\s*###/misU',
$input,
$matches
);
echo "Section: " . $matches['section'] . "\n";
echo "Body: " . $matches['body'] . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment