Created
July 22, 2009 08:09
-
-
Save sergiogomez/151875 to your computer and use it in GitHub Desktop.
Expresiones regulares para borrar saltos de línea en código HTML
This file contains 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
# Borramos los párrafos en blanco | |
text.gsub!(/<p(.)*>(\s)*(<br(\s)*(\/)*>)*(\s)*( )*<\/p>/) { |match| match = ""} | |
# Luego borramos los divs que se hayan quedado vacíos | |
text.gsub!(/<div(.)*>(\s)*(<br(\s)*(\/)*>)*(\s)*( )*<\/div>/) { |match| match = ""} | |
# Y terminamos borrando todo lo que sobra entre etiquetas | |
text.gsub!(/>(\s)*(<br(\s)*(\/)*>)*(\s)*( )*</) { |match| match = ">\n<"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment