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?
the compile() command is typically used for long regex expressions so the programmer doesn't need to write again and again. :-)
in the script i was writing i ended up using the compile option, but left that out in my mail for simplicity.
A good Python book is the New Riders "Python Essential Reference". Its a small book with just the language references, plenty of examples, and its written by the creator of Python.
Thanks for your input! --brad
On Wed, 28 Aug 2002, Brad Noyes wrote:
okay i figured it out, For those intersted ...
text = "FreeBSD" reg_obj = re.compile('(.*)BSD') search_res = reg_obj.findall(text) print search_res[0]
--brad
On Fri, Aug 23, 2002 at 09:37:02PM -0400, Brad Noyes wrote:
Hi All,
I'm starting to learn python. I was looking for a python equivalent to a perl regular expression such as
$_ = "FreeBSD"; /(.*)BSD/;
where $1 would get what ever is between '(...)', 'Free' in this case.
Is there a way i can make use of the () regex operator in python? I can't seem to find an equivalent in python's regex module (re).
Thanks, --brad
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug