Sadly, you happened to choose just the form of Word that does *not* create an RE. For the record, you asked about this expression:
octet = Word(nums,None, 1,3)
Try this:
octet = Word(nums)
print octet.reString
I only generate RE's for Words that don't specify the min and max elements. You will find other RE's generated within other pyparsing elements, such as oneOf, but many times, this is done only for special, easily-regex'ed forms.
-- Paul
(I'm fairly sure the re for this expression would be r"\d{1:3}" or "[0-9]{1:3}", depending on your preferences in RE syntax.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to get the re.pattern string from a ParserElement? I'd like to be able to see the regex generated from constructing ParserElements.
Thanks,
Joey
Joey -
Sadly, you happened to choose just the form of Word that does *not* create an RE. For the record, you asked about this expression:
octet = Word(nums,None, 1,3)
Try this:
octet = Word(nums)
print octet.reString
I only generate RE's for Words that don't specify the min and max elements. You will find other RE's generated within other pyparsing elements, such as oneOf, but many times, this is done only for special, easily-regex'ed forms.
-- Paul
(I'm fairly sure the re for this expression would be r"\d{1:3}" or "[0-9]{1:3}", depending on your preferences in RE syntax.)