Re: backreference in regexp
- From: "Fredrik Lundh" <fredrik@xxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 13:29:20 +0100
Schüle Daniel wrote:
> Hello @all,
>
> >>> p = re.compile(r"(\d+) = \1 + 0")
> >>> p.search("123 = 123 + 0")
>
> 'search' returns None but I would expect it to
> find 123 in group(1)
>
> Am I using something that is not supported by Python
> RegExp engine or what is the problem with my regexp?
plus matches one or more instances of the previous item. to make
it match a plug sign, you have to escape it:
p = re.compile(r"(\d+) = \1 \+ 0")
</F>
.
- Follow-Ups:
- Re: backreference in regexp
- From: Schüle Daniel
- Re: backreference in regexp
- References:
- backreference in regexp
- From: Schüle Daniel
- backreference in regexp
- Prev by Date: Re: test whether 2 objects are equal
- Next by Date: Re: Having Trouble with Scoping Rules
- Previous by thread: backreference in regexp
- Next by thread: Re: backreference in regexp
- Index(es):
Relevant Pages
|