3 ms·
There are a lot of really useful use-cases between not using regexp and using regexp to parse email addresses. For example, our system needs to handle containe
by magicalhippo 6y ago
There are a lot of really useful use-cases between not using regexp and using regexp to parse email addresses.
For example, our system needs to handle container numbers[1] as part of an official form, and we check them for correctness to avoid rejection of the form.
As far as we're concerned the container number consist of four letters and seven digits. However the user is allowed to submit a container number with a hyphen or a space between the letters and the digits.
Writing a regex that checks for a properly formatted container number is quick, easy to understand and a lot less convoluted than most alternatives.
[1]: https://en.wikipedia.org/wiki/ISO_6346 https://en.wikipedia.org/wiki/ISO_6346