Thread: function re()
View Single Post
Old 06-22-2014, 04:36 AM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
That just uses the standard python regex re() module, running the regex "[.]$" and replacing it with "" -- the dot is surrounded by brackets to escape its special meaning as match-any-one-character, but you could do the same with "\.$" and of course, the Dollar sign matches the end-of-line border. So you are matching a dot (not any-character) followed by the end of the field.

A regex to match any dot would be "\." since it doesn't only look for the one right before the end-of-line border as indicated by "$".

In order to better understand regex, you may wish to read a tutorial, like the one here: http://www.regular-expressions.info

Last edited by eschwartz; 06-22-2014 at 04:39 AM.
eschwartz is offline   Reply With Quote