
December 11th, 2008, 01:16 AM
|
|
|
Although learning regex would be better by starting with some basic tutorials, here's a demo:
PHP Code:
$text = '123/abc/xyz/123456789@192.168.0.1';
echo preg_replace('/^.*?(\d+)@.*$/', "$1", $text);
// or
if(preg_match('/\d+(?=@)/', $text, $match)) {
echo "\n" . $match[0];
}
|