How does one define a pattern for a "word with at least one non-digit character" (anywhere in the word) using pyparsing Word() and friends?
The regex solution would be:
Regex("[a-z0-9]+[a-z][a-z0-9]+")
I tried things along the line of:
Combine(Optional(Word(alphanums)) & Word(alphas))
There must be a solution based on FollowedBy / NotAny / SkipTo but I have not figured that out.
I actually think the Regex you would want would be:
Regex("[0-9]*[a-z][a-z0-9]*")
So putting this together using pyparsing classes would be:
Combine(Optional(Word(nums)) + Word(alphas,alphanums))
But at parse time, the Regex will be much faster.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.