Invalid input data should not raise an error, it should just return the normal failure/fallback result. The fact that the input is used to create a regular expression is an implementation detail, that shouldn't cause observable behavior. This change will make sure all user input is escaped so it is not interpreted as a regular expression.
If you do want to allow regular expression searches, it should require the user passing a regular expression, and the method should check for it explicitly:
Invalid input data should not raise an error, it should just return the normal failure/fallback result. The fact that the input is used to create a regular expression is an implementation detail, that shouldn't cause observable behavior. This change will make sure all user input is escaped so it is not interpreted as a regular expression.
If you do want to allow regular expression searches, it should require the user passing a regular expression, and the method should check for it explicitly: