Created
June 9, 2011 09:38
-
-
Save michaelcontento/1016425 to your computer and use it in GitHub Desktop.
Simple regex for @joemanaco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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