Hay all, i need help making a regex. Th开发者_JS百科e string must contain a "-" and must not contain a ".".
Can someone help me please.
You don't need a regex for that:
if (strpos($string, '-') !== false && strpos($string, '.') === false)
//do what you want...
Don't know about php, but this should do it:
^[^.]*-[^.]*$
no need regex for this, one method is to use strpos
strpos($mystr,"-" ) !== FALSE && strpos($mystr,"." ) === FALSE
精彩评论