Ultimate Web Tips

your Wordpress, jQuery, PHP, MySQL, Linux and CSS guide to a successful website
Read more:
Posts Tagged ‘preg_replace’

November 29th, 2011

Replace html tags with regexp

No Comments, PHP, by Joakim Ling.

Regular expressions are an easy way to match or replace pieces of your content, but can be tricky if you are new to it. Here are a few examples to replace html tags.

The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl, with just a few differences. Some features that appeared in Python and PCRE before they appeared in Perl are also available using the Python syntax, there is some support for one or two .NET and Oniguruma syntax items, and there is an option for requesting some minor changes that give better JavaScript compatibility. from original documentation PHP PCRE

March 25th, 2011

Detect the color brightness with PHP

No Comments, PHP, by Joakim Ling.

A while ago I had a lot of background colors stored in a database. Rather then manually pick a text color that will be visible on the background I created a PHP function that will do the trick for me.