Source code:
$output = $_REQUEST['text'];
$output = preg_replace('/.*set\/\?set\=a\.([0-9]{10,20})\.[0-9]{5,6}.*/i', '$1', $output);
echo 'Output: '.$output;
Tests:
Test string 1: Random Text
Test string 2: Facebook Album Link (http://www.facebook.com/media/set/?set=a.225787357502291.56754.225786897502337&type=3)
Test string 3: Album ID (225787357502291)
For additional tests, put whatever you want after ?text= in the url, to see what the regexp does with it.
Explanation of the regexp: on php.net
preg_replace($search_pattern, $replacement_text, $input_text);
expreg may look like a mess, but once you know to learn it, it aint that bad, lets take a look at the search pattern I've chosen.
First of all, \ is used to escape the functions of other symbols, a ? means any random symbol, though escaped as this \? it means what it is, a questionmark.
$search_pattern
/.*set\/\?set\=a\.([0-9]{10,20})\.[0-9]{5,6}.*/i
/ - always start with a /
.* - any symbol, any lenght
set\/\?set\=a\. - represents set/?set=a.
([0-9]{10,20})\. - any number 0-9 with a lenght of 10 to 20 numbers, followed by a . the numbers are inside paranthesis and can be used in the replacement text as $1
[0-9]{5,6} - any number 0-9 with a lenght of 5 to 6 numbers
.* - any symbol, any lenght
/i - case insensitive search
$replacement_text
$1 - outputs what I've put in paranthesis in the pattern, but it could've been anything else aswell, for example "I want '$1' jars of peanutbutter".
$input_text
This is the string where preg_replace searches, can be plain text, numbers, symbols, or a variable.
All in all, if the input is formated as [anything here]set/?set=a.([random numbers, lenght 10-20]).[random numbers, lenght 5-6][anything here],
preg will replace it with those numbers withing the paranthesis.