Daniel works on a web service where users sell and buy secondhand books. In particular, user can store title and a description of a book. Before saving in DB data gets validated:
After a while Daniel finds wrong data in the database. For instance, some books have html tags in their descriptions. Why validation didn’t catch them?
Once a programmer had a problem. He thought he could solve it with a regular expression. Now he has two problems ^_^
The source of problems is regexp
m// searches a string for a pattern match,
so if the string contains at least one allowed character, it will pass the validation.
Daniel should at least specify the beginning and the end of the string: