Skip to content

Instantly share code, notes, and snippets.

@otac0n
Last active September 2, 2016 19:33
Show Gist options
  • Save otac0n/8d69c5385e92815b19d08fec0628a4d1 to your computer and use it in GitHub Desktop.
Save otac0n/8d69c5385e92815b19d08fec0628a4d1 to your computer and use it in GitHub Desktop.
Cleaning Regexes
Remove trailing whitespace:
Pattern: [ \t]+(?=[\r\n])
Replace: ""
Replace tabs with spaces:
Pattern: (?<=^([^\t\r\n]{4})*)\t
Replace: " "
Pattern: (?<=^([^\t\r\n]{4})*[^\t\r\n]{1})\t
Replace: " "
Pattern: (?<=^([^\t\r\n]{4})*[^\t\r\n]{2})\t
Replace: " "
Pattern: (?<=^([^\t\r\n]{4})*[^\t\r\n]{3})\t
Replace: " "
Remove multiple blank lines:
Pattern: (?<=(\r\n){2})(\r\n)+
Replace: ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment