What does the # sign do differently than the /?
$output = preg_replace('#[^A-Za-z0-9]#i', '', $input);
$output = preg_replace('/[^A-Za-z0-9]/i', '', $input);
And what does the letter i do after /[^A-Za-z0-9]/?
Also what does the ^ mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In some languages, it does not matter what type of character starts or ends the pattern portion of the regular expression, so long as it is the same at the beginning and the end (I believe this is a holdover from Perl, arguably the first great regex language). Since PHP follows this line of thought,
#and/are equivalent.i= “Make this search case insensitive”[^...]= exclude everything between the square brackets (^ basically means “exclusion” in this context).You can learn a lot about regular expressions here.