---
title: "ereg() is deprecated, long live preg()!"
description: "We help designers, developers, hobbyists and business owners get the most out of the Joomla CMS.  Join us at our free monthly meetups, and let us help you with your Joomla projects."
url: "https://www.joomlalondon.co.uk/jugl-joomla-news/ereg-is-deprecated-long-live-preg"
date: "2026-08-24T23:45:05+00:00"
language: "en-GB"
---

#  ereg() is deprecated, long live preg()!

    Details    Written by: [Gary Barclay](https://www.joomlalondon.co.uk/organisers/gary-barclay)   Category: [News](https://www.joomlalondon.co.uk/jugl-joomla-news)    Published: 22 January 2013    Last Updated: 12 January 2018  If you manage websites and have gone through or about to go update PHP to 5.3, you will almost certainly come accross the following error on your sites as a result. You may not even have know about the upgrade and suddenly start seeing these warnings all over your site:

ereg-is-deprecated in ..

If you upgraded to PHP 5.3, chances are high you’re going to run into a few warnings or *deprecated function* messages. An example is the `ereg` family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible `preg` family.

To migrate ereg():

ereg('\\.(\[^\\.\]\*$)', $this-&gt;file\_src\_name, $extension);

becomes

preg\_match('/\\.(\[^\\.\]\*$)/', $this-&gt;file\_src\_name, $extension);

Notice that the pattern (`\.([^\.]*$)`) is wrapped with `/ /`, which are RegExp delimiters. If you find yourself escaping `/` too much (for an URL for example), you might want to use the `#` delimiter instead.

The full article "[Fix `ereg is deprecated` errors in PHP 5.3](http://www.devthought.com/2009/06/01/textboxlist-04-on-demand-suggestions/ "Fix `ereg is deprecated` errors in PHP 5.3")" can be read on [devthought.com](http://www.devthought.com "http://www.devthought.com")

but the above snippets provided me enough to work with and clean up several clients sites after my hoster upgraded PHP.

## Schema

```json
{ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "name": "Start", "item": "https://www.joomlalondon.co.uk" }, { "@type": "ListItem", "position": 2, "name": "News", "item": "https://www.joomlalondon.co.uk/jugl-joomla-news" }, { "@type": "ListItem", "position": 3, "name": "ereg() is deprecated, long live preg()!", "item": "https://www.joomlalondon.co.uk/jugl-joomla-news/ereg-is-deprecated-long-live-preg" } ] }
```
