I have a question in regexp –
$template = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template);
but I don’t know what the ‘1’ means, can anyone tell me about this? thanks all.
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.
Simply the first matching group of your regex (in this case, it’s
(.+?)which is inside{}in your regex), so that code replaces things like<!--{test}-->to{test}as our good sir nomaD pointed in his comment below, it’s better to use
$1instead of\\1in your replacement string