$re = '/^(?=\S{8,20}$)(?=\D*\d)(?![0-9_]).{6,18}?(.)\1$/mi';
$str = '+234567899
a_1de*Gg
xy1Me*__
!41deF_hij2lMnopq3ss
C234567890123$^67800
*5555555
sDF564zer""
!!!!!!!!!4!!!!!!!!!!
abcdefghijklmnopq9ss
a_1+Eff
B41def_hIJ2lmnopq3stt
abCDefghijklmnopqrss5
A_4 e*gg
__1+Eff
841DEf_hij2lmnopq3stt
a_1+eFg
b41DEf_hij2lmnopq3st
abCDefghijklmnopqrss
abcdef+++dF
!!!!!!!!!!!!!!!!!!!!
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php