ChrisB: Regex Problem

Beitrag lesen

Hi,

ich muss erkennen, ob in einem Text ein Textteil der Form '****201*-****' (* = beliebige Ziffer)steht.

Mein Regex:
preg_match('/[0-9]{4}[201][0-9][-][0-9]{4}/', $text, $matches);

Bei $text = 'blabal  07122013-7781 blabal';
sollte in $matches[0] doch eigentlich '07122013-7781' stehen. Es steht aber nur '122013-7781' drin.

Was mache ich falsch?

Du willst 201 matchen, suchst an der Stelle aber nur nach einer(!) der Ziffern 2, 0 oder 1.

MfG ChrisB

--
Autocomplete has spoiled me to a point where it happens every so often that I encounter a CAPTCHA, and I just type in the first character … and then wait for the rest of the code to be automatically suggested :/