Discussion:
[Pyparsing] Pyparsing equivalent to regex \1, \2 ... patterns
Loïc Berthe
2014-01-30 21:56:25 UTC
Permalink
Hi,

I would like to define a parser to detect strings containing repeated terms :

- it should match 'A123A', 'B123B'
- but not 'A123B'

With python re module, I would define a parser like this :

parser = re.compile(r'(\w+)(\d+)\1')

Is there a pyparsing equivalent to re \1 and \2 patterns in pyparsing ?
--
Loïc
Paul McGuire
2014-01-30 23:22:14 UTC
Permalink
Check out matchPreviousExpr and matchPreviousLiteral methods.

-- Paul

-----Original Message-----
From: Loïc Berthe [mailto:***@lilotux.net]
Sent: Thursday, January 30, 2014 3:56 PM
To: pyparsing-***@lists.sourceforge.net
Subject: [Pyparsing] Pyparsing equivalent to regex \1, \2 ... patterns

Hi,

I would like to define a parser to detect strings containing repeated terms
:

- it should match 'A123A', 'B123B'
- but not 'A123B'

With python re module, I would define a parser like this :

parser = re.compile(r'(\w+)(\d+)\1')

Is there a pyparsing equivalent to re \1 and \2 patterns in pyparsing ?

--
Loïc

----------------------------------------------------------------------------
--
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import a
virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg..clktrk
_______________________________________________
Pyparsing-users mailing list
Pyparsing-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyparsing-users


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Loading...