Skip to content

Instantly share code, notes, and snippets.

@quadrophobiac
Last active November 24, 2015 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quadrophobiac/5622000c43f4cee80553 to your computer and use it in GitHub Desktop.
Save quadrophobiac/5622000c43f4cee80553 to your computer and use it in GitHub Desktop.
Atom Regexes for File Conversions
omit page numbers - regex that captures any number preceded and followed by a new line
Set up
  1. Download Atom
  2. Find in buffer (aka CMD+F or similar)
  3. toggle use regex option - should look like .*
  4. enter commands below, and leave the replace box blank

options: (\n\d+\n) # any amount of numbers wrapped in new lines, should remove page numbers

(\d+(?!\.)) # match any number NOT followed by a punctuation mark - should be useful for not eliminating footnotes from source

#####Inline footnotes converted and requiring removal (\n\d+\s.*) # presumes that the footnotes will be separated by newlines AND that they begin with a numeral (rather than roman numerals)

#####lots of new line space

  • this will be the last one to execute because Converted Journal Headers, page numbers, etc must be removed first, the latter with expressions above and the former with a manual find and replace

(\n\W\n) # any non word wrapped in newlines

(\n.\n) # any character wrapped in newlines

find and replace new lines with a space - useful for when calibre doesn't omit newlines as you'd like

.\n+. # in find box, find any char followed by one of more newlines and followed by another char

$1 $2 # in the replace box, takes first matched char appends whitespace and next found char

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment