I need a regular expression to find all the lines that begins with /*
$num_queries = preg_match_all(
'REG_EXP',
file_get_contents(__DIR__ . DIR_PLANTILLAS . '/' . 'temp_template.sql')
);
I try this '^\/\*.*' but it does not work.
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.
If you use this string:
/^\/\*.*/in thepreg_match()function, it’ll work. This pattern matches/*followed by maybe some text.Make sure the regular expression will be performed on each line. I recommend that you first split the string (file contents) by a newline. You can use the function
preg_split()in order to do so.If you don’t want to split the file contents by each line first, then you can use the following pattern:
/(^|\n)\/\*(.*)/. That pattern matches first either the beginning of the string or a newline, followed by/*, followed by maybe some text.Notice that in the patterns
/^\/\*.*/and/(^|\n)\/\*(.*)/the/is used as delimiter. That means that further occurences of/must be escaped.