RegExp question

Tim Chase python.list at tim.thechases.com
Tue Apr 11 14:51:24 EDT 2006


> I would like to form a regular expression to find a few
> different tokens (and, or, xor) followed by some variable
> number of whitespace (i.e., tabs and spaces) followed by
> a hash mark (i.e., #). What would be the regular
> expression for this?


	(and|or|xor)\s*#

Unless "varible number of whitespace" means "at least *some* 
whitespace", in which case you'd want to use

	(and|or|xor)\s+#

Both are beautiful and precise.

-tim







More information about the Python-list mailing list