Skip to content

Instantly share code, notes, and snippets.

@fstamour
Last active October 19, 2015 02:18
Show Gist options
  • Save fstamour/1e1d4f5bb4a6758ea570 to your computer and use it in GitHub Desktop.
Save fstamour/1e1d4f5bb4a6758ea570 to your computer and use it in GitHub Desktop.
# Disclaimer, not tested yet, I did the equivalent in vim.
# curl/wget this: https://moodle.polymtl.ca/pluginfile.php/69155/mod_folder/content/0/INF4420a%20intra%20A2014_version%20AAAA0001%20avec%20solution.pdf?forcedownload=1
# Copy the text in it, from the 1st question to the last.
# Remove Q5 and Q6 because they didn't survived the Ctrl-C Ctrl-V.
# Then
# 1st regex 2nd regex 3rg regex 4th regex Buffer (not avail on all system)
sed -ir -e 's/(^[0-9]{0,2}\..*)/\n\1/g' -e 's/^[a-e]/\ [ ] \1/g' -e '/^INF/d' -e '/^Poly/d' <FILENAME> | sponge <FILENAME>
# -r on BSD (so OSX) is -E
# -i is probably a gnu extension
# If sponge is not available, just redirect to a temporary file, and rename the tmp file to <FILENAME> afterward.
#
# Regex explanations:
# 1. Add a newline before every line that begins by "X." or "XX." where X is a digit.
# 2. Add " [ ] " in front of every line that begins by "X." where X is a letter betwen 'a' and 'e' inclusivly.
# 3 and 4. Delete lines starting with "INF" and "Poly" respectivly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment