Sometimes using preg_replace I get some errors, when this happends you need
to add a / at the start and the end of the regular expresion:

preg_replace('/^[A-Za-z]/', '', $contents);


You might like this tool, which shows live highlighting of regular expressions:
http://www.gskinner.com/RegExr/

        Suppose the correct regexp is ^[A-Za-z]+

Once you figure out the correct regular expression, surround it with any delimiter, typically slashes, in addition to being quoted for the PHP function. Though regular expressions are typically delimited with slashes, you can use ampersands or commas or other symbols. (This is helpful if your regular expression is attempting to match slashes; if you use a non-slash delimiter, you won't need to escape the slashes.)

        preg_replace('/^[A-Za-z]+/', '', $contents);
                or
        preg_replace('@^[A-Za-z]+@', '', $contents);

After the closing delimiter, but before the closing quote mark, you can use flags such as i, s, m, or x.

preg_replace('/^[A-Z]+/i', '', $contents); // [A-Z] becomes case (i)nsensitive

The flags i, s, m, and x correspond to the checkboxes ignoreCase, dotall, multiline, and extended, respectively, in the above tool.

Richard



_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to