mazek_59373
Mar 02, 2009Nimbostratus
regexp
Hi,
I'm trying to match via a simple regexp an URI. It can be in a form of:
/sth/digits
/sth/digits.digit
/sth/digits_digit
example U...
Maybe something like this?
% regexp {[/\w]*/(\d+)[._\d]*} /letters/123456_789 unused id
1
% puts $id
123456
% regexp {[/\w]*/(\d+)[._\d]*} /letters/123456.789 unused id
1
% puts $id
123456
% regexp {[/\w]*/(\d+)[._\d]*} /letters/123456 unused id
1
% puts $id
123456
% regexp {[/\w]*/(\d+)[._\d]*} /123456 unused id
In case the regex gets mangled on the forums, try this with the spaces removed:
regexp { [ / \ w ] * / ( \ d + ) [ . _ \ d ] * } $uri unused id
$id will have the value you're looking for.
Aaron