/ Published in: PHP
                    
                                        
This is a regular expression to match a Slug. Slug that contains hyphens ("-").
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/^[a-z0-9-]+$/
To use this expression follow the code below.
//Save the expression in a variable.
$correct_slug = "/^[a-z0-9-]+$/";
//some input from a user through a text field or from a server.
$user_input = $_REQUEST['sometext'];
//match the two input's and save it in a variable.
//Condition goes here.
if(slug_match){
echo "Correct Input";
}
else{
echo "Incorrect Input";
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                