Table of Content
Introduction
You will find here some questions/problems that are frequently seen on IRC, related more or less to PHP. I'll add things when I find the time/ideas,
FAQ 1: preg_* error: Unknown modifier
Unlike POSIX regex functions, functions using PCRE like preg_match, preg_replace and preg_split use a different format for their pattern argument. PCRE supports some modifiers that are passed within the pattern argument. Thus, you need to delimit the actual regex pattern from the modifiers. That's why delimiters are required in your pattern argument. The pattern syntax required is the following:
pattern ::= startingDelimiter regex endingDelimiter [modifiers]
There are many possible delimiters (like "/", "#", "~", "!", "@", "%" ...) you should pick one not used in your regex, or you would have to escape it.
<?php
preg_match('#http://myurl/([^/]+)/my_file#', $input);
preg_match('~http://myurl/([^/]+)/my_file.*$~ms', $input); // using the multiline and dotall modifier
?>
RSS (general)