Php - how to check the correct expression?

I need to check the user input, which can be a regular expression for filtering fields in his / her own application, how can I check the correctness of this regular expression?

+5
source share
1 answer

Pass it to the dummy call preg_match() and see if it returns false (indicating an error)?

Note :: Depending on where you plan to run this application, I would question the decision to allow users to do this. You can set yourself up for a denial of service attack; all malicious users need to provide an incredibly long complex string of regular expressions, and your server will stop.

+4
source

Source: https://habr.com/ru/post/912631/


All Articles