php - Regex Help - need to allow % in a regex formula -


i have function checks whether url contains special characters , want add '%' allowed i'm using %prefix% container. i'm relatively new regex , wondering if me add % allowed list. function below:

function specialchars($url) {            if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url) != true)     {         $this->errors[] = "please remove special characters";                }        } 

thanks in advance. regards,

as http://www.regular-expressions.info/reference.html explains, [] (and contents) defines character class.

since % not metacharacter inside of character classes (or @ all) can place in character classes want allowed in, example [a-z0-9-%]


Comments