MRAB pyt...@mrabarnett.plus.com wrote:
On 16/12/2011 21:04, John Gordon wrote:
Inmailman.3737.1324054637.27778.python-l...@python.org Devin
Jeanpierrejeanpierr...@gmail.com writes:
You could use re.finditer to find the longest match, and then
replace it manually by hand (via string
On Dec 16, 11:49 am, John Gordon gor...@panix.com wrote:
I'm working with IPv6 CIDR strings, and I want to replace the longest
match of (:|$)+ with :. But when I use re.sub() it replaces
the leftmost match, even if there is a longer match later in the string.
Typically this means that
On Mon, Dec 19, 2011 at 4:15 PM, t...@thsu.org wrote:
On Dec 16, 11:49 am, John Gordon gor...@panix.com wrote:
I'm working with IPv6 CIDR strings, and I want to replace the longest
match of (:|$)+ with :. But when I use re.sub() it replaces
the leftmost match, even if there is a
According to the documentation on re.sub(), it replaces the leftmost
matching pattern.
However, I want to replace the *longest* matching pattern, which is
not necessarily the leftmost match. Any suggestions?
I'm working with IPv6 CIDR strings, and I want to replace the longest
match of
You could use re.finditer to find the longest match, and then replace
it manually by hand (via string slicing).
(a match is the longest if (m.end() - m.start()) is the largest --
so, max(re.finditer(...), key=lambda m: (m.end() = m.start()))
-- Devin
P.S. does anyone else get bothered by how
On 16/12/2011 16:49, John Gordon wrote:
According to the documentation on re.sub(), it replaces the leftmost
matching pattern.
However, I want to replace the *longest* matching pattern, which is
not necessarily the leftmost match. Any suggestions?
I'm working with IPv6 CIDR strings, and I
On Fri, Dec 16, 2011 at 10:36 AM, MRAB pyt...@mrabarnett.plus.com wrote:
On 16/12/2011 16:49, John Gordon wrote:
According to the documentation on re.sub(), it replaces the leftmost
matching pattern.
However, I want to replace the *longest* matching pattern, which is
not necessarily the
On Fri, Dec 16, 2011 at 10:57 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Fri, Dec 16, 2011 at 10:36 AM, MRAB pyt...@mrabarnett.plus.com wrote:
On 16/12/2011 16:49, John Gordon wrote:
According to the documentation on re.sub(), it replaces the leftmost
matching pattern.
However, I want to
On 16/12/2011 17:57, Ian Kelly wrote:
On Fri, Dec 16, 2011 at 10:36 AM, MRABpyt...@mrabarnett.plus.com wrote:
On 16/12/2011 16:49, John Gordon wrote:
According to the documentation on re.sub(), it replaces the leftmost
matching pattern.
However, I want to replace the *longest* matching
In article jcfsrk$skh$1...@reader1.panix.com,
John Gordon gor...@panix.com wrote:
I'm working with IPv6 CIDR strings, and I want to replace the longest
match of (:|$)+ with :. But when I use re.sub() it replaces
the leftmost match, even if there is a longer match later in the string.
In mailman.3737.1324054637.27778.python-l...@python.org Devin Jeanpierre
jeanpierr...@gmail.com writes:
You could use re.finditer to find the longest match, and then replace
it manually by hand (via string slicing).
(a match is the longest if (m.end() - m.start()) is the largest --
so,
In mailman.3742.1324058429.27778.python-l...@python.org Ian Kelly
ian.g.ke...@gmail.com writes:
I'm also looking for a regexp that will remove leading zeroes in each
four-digit group, but will leave a single zero if the group was all
zeroes.
pattern = r'\b0{1,3}([1-9a-f][0-9a-f]*|0)\b'
In roy-7c4e8a.13361716122...@news.panix.com Roy Smith r...@panix.com writes:
Having done quite a bit of IPv6 work, my opinion here is that you're
trying to do The Wrong Thing.
What you want is an IPv6 class which represents an address in some
canonical form. It would have constructors
On 16/12/2011 21:04, John Gordon wrote:
Inmailman.3737.1324054637.27778.python-l...@python.org Devin
Jeanpierrejeanpierr...@gmail.com writes:
You could use re.finditer to find the longest match, and then replace
it manually by hand (via string slicing).
(a match is the longest if
On 12/16/2011 1:36 PM, Roy Smith wrote:
What you want is an IPv6 class which represents an address in some
canonical form. It would have constructors which accept any of the
RFC-2373 defined formats. It would also have string formatting methods
to convert the internal form into any of these
15 matches
Mail list logo