preg_match for string - string [关闭]

Say I have an array:

$length =['pre-tied','self-tie','large','small'];

How would the preg_match command look like If I wanted to get values of 'string-string' format from the specific array?

foreach($length as $size)
 if(preg_match("/^[A-Z,-,A-Z]$/i",$size))
    do something

or

foreach($length as $size)
 if(preg_match("/^[A-Z,-,A-Z]$/i",$size));
    do something

Actually, I think the second one does not even make sense but since I am new to regular expressions I cannot be sure..

When approaching regular expressions, the way I tackle these problems is starting from the very specific and looking for patterns and making it very general.

Simplest match:

 /^pre-tied$/

Matches e-t of pre-tied

 /^[A-Za-z]-[A-Za-z]$/

Then if you are trying to match single-hyphen words, use one of the repeating operators (+, *)

 /^[A-Za-z]+-[A-Za-z]+$/

We can even make the regular expression more complex, like in this similar question, but I think the final regular expression that I came up with should match both words in that array.