I need to extract a substring from an email subject only if valid. The valid substring is like:
ab-2011-0023ad
or ac-2011-0023ad.r1
, only two dashes are allowed, number of letters after second dash varies, but only alphanumeric with one dot or without dot.
I wrote this one, but if I put after second dash an illegal character, the regexp returns partial substring not empty
/([a-z0-9]{0,3}[-]\d{4}[-][a-z0-9.]+)\S/i
i.e.: "this is an email with ab-2011-0023:ad document"
, I expect from regexp to return empty array not [0] => ab-2011-0023
.