On Wed, 28 Aug 2002, Brad Noyes wrote:
On Wed, Aug 28, 2002 at 12:06:08PM -0400, Phillip G Deneault wrote:
I didn't see this when you sent it the first time...
There is a another way to do this.
text = "FreeBSD" results = re.search(r'(.*)BSD', text) print results.groups(1) Yes, i saw this somewhere as well.
Question: what is the r'...' used for, and what does it mean?
It denotes a 'raw' string input and add special characters accessed by the \ key. For instance r'\<html\>(.*)\<\/html\>' searches between the <html></html> tags. There are other characters too, for instance, \d only matches number digits and is the equivalent to r'[0-9]'. If you use this method, its easiest to just leave the r'' notation in. That way, everything is consistent and you can use a whole list of shortcuts. Phil -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Phil Deneault "We work in the dark, We do what we can, deneault@wpi.edu We give what we have. Our doubt is our passion, WPI NetOps and our passion is our task. The rest is the InfoSec maddness of art." - Henry James -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-