Version 1.4.5 includes a couple of new helper methods, matchPreviousLiteral
and matchPreviousExpr, for exactly this situation. I think there is some
sample code in the HTML docs, if not, write back and I'll post some sample
code using these methods.
There is a current known bug if you are using parse actions with these two
methods, I've got a fix in the works, just need to push out the next release
if its critical for you.
-- Paul
-----Original Message-----
From: pyp...@li...
[mailto:pyp...@li...] On Behalf Of Waylan
Limberg
Sent: Thursday, January 25, 2007 11:00 AM
To: pyp...@li...
Subject: [Pyparsing] matching a previous match
I'm trying to match an string enclosed in backticks. Rather than using an
escape character, the string is simply wrapped in more backticks.
Here are some examples:
`foo` => foo
``foo`bar`` => foo`bar
`` `bar` `` => `bar` #note the spaces in this one
This is easy in regex:
(?P<backtick>`+)(?P<string>.*?)(?P=backtick)
Of course, the trick is that the ending string of backticks must exactly
match the opening string of backticks.
Sure I can use Regex() for this, but I'm trying to figure you how to do that
without regex. How can I refer back to a previous match?
--
----
Waylan Limberg
wa...@gm...
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's
Techsay panel and you'll get the chance to share your opinions on IT &
business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Pyparsing-users mailing list
Pyp...@li...
https://lists.sourceforge.net/lists/listinfo/pyparsing-users
|