-
Hi Paul, 2 recent pypi libraries are designed to make regular expressions easier to construct: I was looking at both of them and asking myself why I would ever use either if I have PyParsing. After examining the PyParsing docs, one thing that I did not see was the ability to specify an exact amount of a particular character set. Under expression subclasses we see an example of a us phone number:
But first of all, a number doesnt typically include letters. And second of all, the amount of characters in the various elements of a phone number are specific. So, keeping to the topic of this post, how does one specify an exact number of characters for an element of a PyParsing expression? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To specifically answer your question, Word can take min, max, and exact arguments to have more control over the number of matched characters. We don't see this in us_phone_number because this is an ambiguous expression. It could match 123-4567 or 012-345-6789. To make this a little less ambiguous, we could write it as:
|
Beta Was this translation helpful? Give feedback.
To specifically answer your question, Word can take min, max, and exact arguments to have more control over the number of matched characters.
We don't see this in us_phone_number because this is an ambiguous expression. It could match 123-4567 or 012-345-6789. To make this a little less ambiguous, we could write it as: