I want to check weather or not a string contains (alpha numeric characters and "-") only without spaces and other stuff...
*but it must contain atleast one alpha numeric character and a maximum of two "-"
example:
value could be "-asd-"or "ads-" or "asd7" or "ads or "a-7ds"

I am currently using (for alpha numeric characters only):

if (preg_match('/^[A-Za-z0-9]+$/', $value)) {
	return true;
}

Thanks
*Sorry for the amatuer way i post my question, but i just wanted to be clear
help would be appreciated

preg_match('/^[\w\-]+$/', $value)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.