Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Regular expression match objects - compact syntax?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Diez B. Roggisch, post: 1803039"] Usually we don't bothe too much. But it has been suggested to do something like this: class Matcher: def __init__(self, rex): self.rex = rex def match(self, s): self.m = self.rex.match(s) return not self.m is None Then you can do m = Matcher(rex) if m.match(line): print m.m Of course you can enhance the class mather so that all methods it does not define by itself are delegated to self.m, which would be more convient. But I'm currently too lazy to write that down :) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Regular expression match objects - compact syntax?
Top