darkfreaks Posted September 23, 2009 Share Posted September 23, 2009 not sure why , is the regex right for dash and underscores <?php // underscores/dash if(preg_match("/([_-])/", $password)) { $strength++; } ?> Link to comment https://forums.phpfreaks.com/topic/175241-solved-preg_match-not-working/ Share on other sites More sharing options...
Mark Baker Posted September 23, 2009 Share Posted September 23, 2009 You need to escape - as \- because it's used for defining ranges (e.g. /[A-Z]/) Link to comment https://forums.phpfreaks.com/topic/175241-solved-preg_match-not-working/#findComment-923613 Share on other sites More sharing options...
darkfreaks Posted September 23, 2009 Author Share Posted September 23, 2009 still doesnt work now i have /([_\-])/ Link to comment https://forums.phpfreaks.com/topic/175241-solved-preg_match-not-working/#findComment-923616 Share on other sites More sharing options...
thebadbad Posted September 23, 2009 Share Posted September 23, 2009 You need to escape - as \- because it's used for defining ranges (e.g. /[A-Z]/) Not when it's placed first or last inside the character class. @OP What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/175241-solved-preg_match-not-working/#findComment-923644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.