Question: I want to simulate stroking a carpet, so you would have a graphic of a fury carpet and with your finger you can move around and stroke it. I need to shift pixels and create some fake distortion around where I am touching. 

Anyone have any tips ?

Firstly I guess do I have enough to work with assuming I have 1 jpeg of the material. Not any skeleton or 3d file, just a flat image

Answer: 
You forgot to [anchor](http://www.regular-expressions.info/anchors.html) the regex. Also, if you only want to allow four-digit years, you have to make that explicit:

```
~^(?P<day>[0-9]{1,2})[.](?P<month>[0-9]{1,2})[.](?P<year>[0-9]{4})$~

```

`^` and `$` only match at the start and end of the string, ensuring that your regex doesn't match the `12.12.12` substring in `2012.12.12`.

If you want to forbid leading zeroes, use

```
~^(?P<day>[1-9][0-9]?)[.](?P<month>[1-9][0-9]?)[.](?P<year>[0-9]{4})$~

```

Of course, this doesn't do any sanity checking (99.99.9999 passes this regex), but checking for a valid date is something [you shouldn't be doing with a regex anyway](https://stackoverflow.com/a/4291747/20670).
Try this:

```
$regex = '#^[0-9]{2}.[1-9][0-9]{0,1}.[0-9]{4}$#';

```

It should allow the 2 first formats, not the others.