Test your regular expressions online
Wednesday, June 17th, 2009Speaking of regular expressions, I found out you can test them online at regexpal.com. Neat.
Speaking of regular expressions, I found out you can test them online at regexpal.com. Neat.
Aside: I just discovered the very useful Emacs regex builder tool. Type M-x regexp-builder.
I wanted a regular expression to match the pattern of mutt mail edit buffers, to apply mail-mode, but I did not want to match the muttrc and mutt.hooks files I have.
Mail edit buffers get a pattern that starts with “mutt”, followed by [...]
I was confused that bash would expand some patterns nicely to match filenames when I was on the commandline, but the same pattern would not work from inside a shell script. For example, the following pattern would nicely match all files in the current directory not having an “Rnw” or “tex” extension on the commandline:
ls [...]
Replacing whitespace, lifted directly from the handy collection of sed one-liners at Sourceforge:
Delete all leading whitespace from line (tabs and spaces):
sed ’s/^[ \t]*//’
Delete whitespace at end of line:
sed ’s/[ \t]*$//’
Delete leading and trailing whitespace:
sed ’s/^[ \t]*//;s/[ \t]*$//’
Many things are easiest to learn by looking at examples. I find this to be especially true for sed. Sed stands for “stream editor”, and it is very handy to perform bulk editing of text files. To get started, I refer you to this very nice tutorial. I’m planning to archive some of the small [...]