preg_match( '/[a-z1-9]{2,5}-\d(\.\d)?/', "example.com - ABC-1.0", $match);
This is working at http://gskinner.com/RegExr/. I get the expected matches there - it matches "ABC-1.0". But not using preg_match. The matches array is empty.
preg_match( '/[a-z1-9]{2,5}-\d(\.\d)?/', "example.com - ABC-1.0", $match);
This is working at http://gskinner.com/RegExr/. I get the expected matches there - it matches "ABC-1.0". But not using preg_match. The matches array is empty.
You need to use delimiters when using PCRE functions. You also need the regex to be case insensitive.
preg_match('/[a-z1-9]{2,5}-\d(\.\d)?/i'
You can add case insensitivity inside the regex using a modifier group.
Also note that the group 1 is optional, so if it doesn't find a .number
group 1 will be empty.
/(?i)[a-z1-9]{2,5}-\d(\.\d)?/
If you know the ABC
part should always match uppercase letters, you can make it explicit by using [A-Z1-9]
Better to be explicit than vague when it comes to regexes.