RegexBuddy "traducirá" cualquier expresión regular para usted. Cuando se alimenta el ejemplo de expresiones regulares, que da salida:
((^[ \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) «*»
Esto se parece bastante intimidante en forma de texto, pero es mucho más fácil de leer en el formulario HTML (que no puede ser reproducido aquí) o en la misma RegexBuddy. También señala problemas comunes (como la repetición de grupos de captura que probablemente no se desee aquí).
Tal vez algunas herramientas en http://stackoverflow.com/questions/32282/regex-testing-tools ayudará. – kennytm
Yo tampoco. Siempre uso 6-10 líneas de código con explode/join/strstr/substr (PHP) en su lugar. Más fácil de entender, mantener e incluso escribir. – ern0
No todos los idiomas o bibliotecas que admiten expresiones regulares funcionarán tan limpiamente como su ejemplo, debido a los espacios en blanco adicionales. –