Ian D wrote:
> Ok I got it.
>
> pchars = re.compile(b'\x00\x00\x00[\0-\xff]')
>
> preceeding b and [0-\xff]
Also possible:
re.compile(b"\0\0\0.", re.DOTALL)
. by default means "any byte except \n", the re.DOTALL flag changes that to
"any byte".
or
re.compile(b"\0{3}.", re.DOTALL)
{3} mean
Ok I got it.
pchars = re.compile(b'\x00\x00\x00[\0-\xff]')
preceeding b and [0-\xff]
> From: dux...@hotmail.com
> To: tutor@python.org
> Date: Sun, 29 Mar 2015 07:55:01 +0000
> Subject: Re: [Tutor] escape character regex
>
wildcard for the last byte as it
changes?
Thanks
> Date: Sat, 28 Mar 2015 20:21:09 -0400
> From: da...@davea.name
> To: tutor@python.org
> Subject: Re: [Tutor] escape character regex
>
> On 03/28/2015 03:37 PM, Ian D wrote:
>> H
On 03/28/2015 03:37 PM, Ian D wrote:
Hi
I run a regex like this:
pchars = re.compile('\x00\x00\x00') #with or without 'r' for raw
Which one did you actually want? The 3 byte sequence consisting of
nulls, or the 12 byte one containing zeroes and backslashes? I'm going
to assume the form
> But if I try to match the extra digits at the end like this:
>
>>pchars = re.compile('\x00\x00\x00\x\d+')
>
> I get an error:
>
>>ValueError: invalid \x escape
You should just be able to say:
pchars = re.compile('\x00\x00\x00..')
because it looks like you're trying to grab at the last two
Hi
I run a regex like this:
>pchars = re.compile('\x00\x00\x00') #with or without 'r' for raw
on a string like this:
>data = "['broadcast', 'd8on\x00\x00\x00\x11broadcast', 'd11on']"
>print "found pchars :",pchars.findall(data)
which returns:
>found pchars : ['\x00\x00\x00']
But if I tr