Skip to content

Instantly share code, notes, and snippets.

@azeemhassni
Created July 9, 2014 06:31
Show Gist options
  • Save azeemhassni/65cf74ed57b8b86dc3fe to your computer and use it in GitHub Desktop.
Save azeemhassni/65cf74ed57b8b86dc3fe to your computer and use it in GitHub Desktop.
Select IF Block using Regular Expressions
<?php
$pat = 'if\(.*\)\s?\{\n?(.*\s\n?)+\}'
$matches = array();
$code = 'if($var != $var2) {
// code
}';
$isFound = preg_match($pat,$code,$matches);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment