On 10/1/10, Steven D'Aprano wrote:
> On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote:
>> >> Here is my test:
>> >> s=re.search(r"[\d+\s+\d+\s+\d]", l)
>> >
>> > Try this instead:
>> >
>> > re.search(r'\d+\s+\D*\d+\s+\d', l)
> [...]
>> Understood. My intent was to ask why my regexp would match anyth
On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote:
> >> Here is my test:
> >> s=re.search(r"[\d+\s+\d+\s+\d]", l)
> >
> > Try this instead:
> >
> > re.search(r'\d+\s+\D*\d+\s+\d', l)
[...]
> Understood. My intent was to ask why my regexp would match anything
> at all.
Square brackets create a charact
On 10/1/10, Steven D'Aprano wrote:
> On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote:
>> Hi, once again...
>> I have a regexp that I am trying to use to make sure a line matches
>> the format: [c*]n [c*]n n
>> where c* is (optionally) 0 or more non-numeric characters and n is
>> any numeric charact
with coffee:
yes = """
v1 v2 5
2 someword7 3
""".splitlines()[1:]
no = """
word 2 3
1 2
""".splitlines()[1:]
import re
pattern = "(\w*\d\s+?)(\w*\d\s+?)(\d)$"
rx = re.compile(pattern)
for line in yes:
m = rx.match(line)
assert m
print([part.rstrip() for part in m.groups()])
f
On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote:
> Hi, once again...
> I have a regexp that I am trying to use to make sure a line matches
> the format: [c*]n [c*]n n
> where c* is (optionally) 0 or more non-numeric characters and n is
> any numeric character. The spacing should not matter. These sh
Alex Hall wrote:
Hi, once again...
I have a regexp that I am trying to use to make sure a line matches the format:
[c*]n [c*]n n
where c* is (optionally) 0 or more non-numeric characters and n is any
numeric character. The spacing should not matter. These should pass:
v1 v2 5
2 someword7 3
whi
Hi, once again...
I have a regexp that I am trying to use to make sure a line matches the format:
[c*]n [c*]n n
where c* is (optionally) 0 or more non-numeric characters and n is any
numeric character. The spacing should not matter. These should pass:
v1 v2 5
2 someword7 3
while these should not