|
|
|
|
|
by jsrn
5328 days ago
|
|
> because those who can benefit from this kind of basic regexp examples are also those who will not understand the limitations. I share your sentiment. The article is certainly useful for learning regexps. But IMHO it should also point to the correct way of doing things - often, the correct way is using a module and thus the resulting code is not much longer than the code in the article. For email address validation: use Email::Valid;
print (Email::Valid->address('john@example.com') ? 'valid' : 'invalid');
as a oneliner: perl -MEmail::Valid -E"say (Email::Valid->address('john@example.com') ? 'valid' : 'invalid');"
Other than installing the Email::Valid module with a cpanm Email::Valid
it is not much longer than the example in the article.https://metacpan.org/module/Email::Valid |
|