Skip to content

Instantly share code, notes, and snippets.

@ivamluz
Last active August 29, 2015 14:03
Show Gist options
  • Save ivamluz/c17ba6151807edc8bb5a to your computer and use it in GitHub Desktop.
Save ivamluz/c17ba6151807edc8bb5a to your computer and use it in GitHub Desktop.
Regex (and PHP code sample) for parsing Drupal .info files
<?php
if (preg_match('/^([a-zA-Z\[\]]+)\s*=\s*(.+)$/', $line, $matches)) {
// $matches[0]: whole line matched
// $matches[1]: property name
// $matches[2]: property value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment