On Thu, 28 Mar 2013 21:00:44 -0700, Victor Hooi wrote:
Is it possible to somehow test for a match, as well as do assignment of
the re match object to a variable?
mo = expression.match(line)
if mo:
...
Many problems become trivial when we stop trying to fit everything into a
single
Victor Hooi wrote:
Hi,
I have logline that I need to test against multiple regexes. E.g.:
import re
expression1 = re.compile(r'')
expression2 = re.compile(r'')
with open('log.txt') as f:
for line in f:
if expression1.match(line):
Victor Hooi victorh...@gmail.com writes:
expression1 = re.compile(r'')
expression2 = re.compile(r'')
[...]
Just a quick remark: regular expressions are pretty powerful at
representing alternatives. You could just stick everything inside a
single re, as in '...|...'
Then use
On Friday, 29 March 2013, Alain Ketterlin wrote:
Victor Hooi victorh...@gmail.com javascript:; writes:
expression1 = re.compile(r'')
expression2 = re.compile(r'')
[...]
Just a quick remark: regular expressions are pretty powerful at
representing alternatives. You could
On 2013-03-29, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:
Victor Hooi victorh...@gmail.com writes:
expression1 = re.compile(r'')
expression2 = re.compile(r'')
[...]
Just a quick remark: regular expressions are pretty powerful at
representing alternatives. You could
On 03/29/2013 04:27 AM, Peter Otten wrote:
(2)
import re
class Matcher:
def __call__(self, expr, line):
result = self.match = expr.match(line)
return result
def __getattr__(self, name):
return getattr(self.match, name)
Perhaps it's a little simpler to
Hi,
I have logline that I need to test against multiple regexes. E.g.:
import re
expression1 = re.compile(r'')
expression2 = re.compile(r'')
with open('log.txt') as f:
for line in f:
if expression1.match(line):
# Do something -
On Thu, Mar 28, 2013 at 9:00 PM, Victor Hooi victorh...@gmail.com wrote:
Hi,
I have logline that I need to test against multiple regexes. E.g.:
import re
expression1 = re.compile(r'')
expression2 = re.compile(r'')
with open('log.txt') as f:
for line in f: