Hey guys, is there any way to check if the givin value is a regex using a regex more details $value = "/^(.*)$/"; $check = preg_match("[missing regex]", $value, $match); PHP: it's pretty simple now, i want someone to give me a regex to check a value if it's a regex if there any other better way of doing this please share it Thanks a lot
Well using a regex for that could become complicated in the long run, would be simpler to make use of php's existing functions to come up with some sort of validation, e.g. to start you can check if the start and ending character are the same then check if their a valid delimiter. Also take alook at preg_quote() - may become useful.
yea i thought of that too, i thought that it would be complicated, i guess ur opinion is mush better, i'll keep it as you told me ,, Thanks for helping me with my script
There is no such thing as a valid regular expression, this is why they are valid and invalid for certain cases. You can however, check if the syntax is correct be doing the following: 1) Check for valid delimiters as dan said. 2) Check for valid modifiers. 3) Check for invalid and closed meta characters. 4) Check for valid character classes.