On Sat, Aug 9, 2014 at 1:49 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Sat, Aug 9, 2014 at 12:52 AM, Paul Wolf <paulwolf...@gmail.com> wrote: >> On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: >>> Have you given any thought to adding a validation mode, where the user >>> provides a template and a string and wants to know if the string >>> matches the template? >> >> Isn't that what regular expressions are? Or do you have a clarifying use >> case? >> >> strgen is provided as the converse of regular expressions. > > The syntax is not equivalent though. You can't take a strgen template, > pass it into the re module, and just expect it to work. > > Also, I'm not sure how best to go about writing a regular expression > for, e.g. "12 or more letters, digits, and punctuation, including at > least one each of uppercase letter, lowercase letter, digit, and > punctuation". I'm fairly certain that language is regular, but > actually matching it with a regular expression would be a nightmare.
To clarify further, validating that *without* using a regular expression is not too terribly difficult, but the value that I see in validating it with a strgen is that one could then be sure that one's string generation and validation were equivalent. In contrast, if you have a strgen for generation and a series of string manipulations for validation, then it's hard to be certain there aren't any differences. -- https://mail.python.org/mailman/listinfo/python-list