Reputation: 41433
Hay all, i need help making a regex. The string must contain a "-" and must not contain a ".".
Can someone help me please.
Upvotes: 0
Views: 168
Reputation: 11553
You don't need a regex for that:
if (strpos($string, '-') !== false && strpos($string, '.') === false)
//do what you want...
Upvotes: 13
Reputation: 342363
no need regex for this, one method is to use strpos
strpos($mystr,"-" ) !== FALSE && strpos($mystr,"." ) === FALSE
Upvotes: 2