RegexBuddy будет «переводить» любое регулярное выражение для вас. При подаче вашего примера регулярного выражения, он выводит:
((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)
Options:^and $ match at line breaks
Match the regular expression below and capture its match into backreference number 1 «((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)»
Match the regular expression below and capture its match into backreference number 2 «(^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Note: You repeated the capturing group itself. The group will capture only the last iteration.
Put a capturing group around the repeated group to capture all iterations. «+»
Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
Match a single character present in the list below «[ \t]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
The character “ ” « »
A tab character «\t»
Match the character “>” literally «>»
Match a single character present in the list below «[ \t]?»
Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
The character “ ” « »
A tab character «\t»
Match any single character that is not a line break character «.+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match a line feed character «\n»
Match the regular expression below and capture its match into backreference number 3 «(.+\n)*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Note: You repeated the capturing group itself. The group will capture only the last iteration.
Put a capturing group around the repeated group to capture all iterations. «*»
Match any single character that is not a line break character «.+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match a line feed character «\n»
Match a line feed character «\n*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Это выглядит довольно устрашающе в текстовой форме, но это гораздо более удобные для чтения в HTML форме (который не может быть воспроизведен здесь) или в самой RegexBuddy. Он также указывает на общие ошибки (например, повторение групп захвата, которые, вероятно, не нужны здесь).
Может быть, некоторые инструменты в http://stackoverflow.com/questions/32282/regex-testing-tools поможет. – kennytm
Я этого не делаю. Я всегда использую 6-10 строк кода вместо explode/join/strstr/substr (PHP). Легче понять, сохранить и даже написать. – ern0
Не каждый язык или библиотека, поддерживающая регулярное выражение, будет работать так же чисто, как ваш пример, из-за добавленного пробела. –