Popular recipes by Peter Kleiweg http://code.activestate.com/recipes/users/2005873/popular/2005-11-16T12:03:18-08:00ActiveState Code RecipesUsing re.match, re.search, and re.group in if ... elif ... elif ... else ... (Python)
2005-11-16T12:03:18-08:00Peter Kleiweghttp://code.activestate.com/recipes/users/2005873/http://code.activestate.com/recipes/456151-using-rematch-research-and-regroup-in-if-elif-elif/
<p style="color: grey">
Python
recipe 456151
by <a href="/recipes/users/2005873/">Peter Kleiweg</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 5.
</p>
<p>A wrapper class for (a small part of) the 're' module, that enables you to do re.match() or re.search() in an 'if' test or 'elif' test and use the result of the match after the test.</p>
Handling of command line arguments: options, arguments, file(s) content iterator (Python)
2004-08-28T21:02:14-07:00Peter Kleiweghttp://code.activestate.com/recipes/users/2005873/http://code.activestate.com/recipes/302262-handling-of-command-line-arguments-options-argumen/
<p style="color: grey">
Python
recipe 302262
by <a href="/recipes/users/2005873/">Peter Kleiweg</a>
(<a href="/recipes/tags/files/">files</a>).
Revision 4.
</p>
<p>Handles arguments for small scripts that need to:
- read some command line options
- read some command line positional arguments
- iterate over all lines of some files given on the command line, or stdin if none given
- give usage message if positional arguments are missing
- give usage message if input files are missing and stdin is not redirected</p>
RE match and replace through operator overloading (Python)
2004-08-29T13:00:39-07:00Peter Kleiweghttp://code.activestate.com/recipes/users/2005873/http://code.activestate.com/recipes/302498-re-match-and-replace-through-operator-overloading/
<p style="color: grey">
Python
recipe 302498
by <a href="/recipes/users/2005873/">Peter Kleiweg</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 2.
</p>
<p>This recipe demonstrates how you can do regular expression matching and replacing with operators.</p>