$re = '/(?:[ebay]*(?:[\/]|[itm=])|^)([0-9]{9,12})/';
$str = '221690103652
http://www.ebay.co.uk/itm/HP-OVU422000-06-MEDIA-CENTER-REMOTE-IR-USB-RECEIVER-/161830504761?ssPageName=STRK:MESE:IT
http://www.ebay.co.uk/itm/like/Classic-1985-Porsche-944-2-5-EXCELLENT-CONDITION-TONS-OF-HISTORY-PART-EX/252112320478?hlpht=true&ops=true&viphx=1&_trksid=p5197.c100068.m2280&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20140211130857%26meid%3D73e99323141844c18d88a2debd9c2309%26pid%3D100068%26rk%3D1%26rkt%3D6%26mehot%3Dpp%26sd%3D121776622006%26clkid%3D276267228855363952&_qi=RTM2063753
http://www.ebay.co.uk/itm/like/PORSCHE-911-CARRERA-SC-3-0-TARGA-SLATE-NOSE-LHD-Turbo-body-tyres-345-35-15/201440886841?hlpht=true&ops=true&viphx=1&_trksid=p5197.c100068.m2280&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20140211130857%26meid%3D2a0f8e2eb452470d930e2a8baf81f305%26pid%3D100068%26rk%3D2%26rkt%3D6%26mehot%3Dpp%26sd%3D121776622006%26clkid%3D276277477609057080&_qi=RTM2063756
http://www.ebay.co.uk/itm/201440886841
http://www.ebay.co.uk/itm/Honda-ANF-Innova-125-3-/301757710737?&_trksid=p2056016.l4276
http://www.ebay.co.uk/itm/171921735372?_trksid=p2057872.m2749.l2648&var=470833174734&ssPageName=STRK%3AMEBIDX%3AIT
http://www.ebay.co.uk/itm/Revell-1-24-Porsche-918-Spyder-New-Plastic-Model-Kit-07026-1-24/181888674810?_trksid=p2047675.c100011.m1850&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D33662%26meid%3Ded9c952f46664e5c93a9b54e6aea0368%26pid%3D100011%26rk%3D4%26rkt%3D10%26sd%3D221869196497
http://www.ebay.co.uk/rcm/v1/Italeri-1-72-1236-FRS-1-SEA-HARRIER-AIRCRAFT-KIT-/?itm=131606934520&_trksid=p2047675.c100010.m1843
http://www.ebay.co.uk/itm/Vauxhall-Opel-Corsa-1-2i-16v-2003-Elegance-SILVER-AIR-CON-/221690103652
221690103652
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php