Last active
August 29, 2015 14:13
-
-
Save dimaqw/7452dff1fe544dcfd892 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
RegExp для обработки метаданных | |
Перейти к: навигация, поиск | |
Для использования в файлах типа vardefs.php | |
Первая строка: регулярка поиска, | |
вторя строка: регулярка замены. | |
array переносится в ту же строку, где знак = или => | |
^([^\n]*?=>?[^\n]*?)\n\s*(array *\() | |
$1 $2 | |
Убираем числовые индексы массивов в сгенерированном шугой коде | |
(\s*)\d =>\s*([^\r\n]+)|\s*\d =>\s*\r?\n|(\s*)\d => (array ?\(\s*\r?\n) | |
$1$2$3$4 | |
Добавляем запятую после каждого элемента массива, записанного на отдельной строке | |
^(\s*.+=>.*[^\(,\s])\s*$ | |
$1, | |
([^\(,;])\r?\n | |
$1 | |
Переносим закрывающую скобку на новую строку | |
(.)\)([^\)]|$) | |
$1\n\)$2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment