CodeIgniter Forums
Help for alpha_numeric_punct - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Help for alpha_numeric_punct (/showthread.php?tid=80253)



Help for alpha_numeric_punct - Secux - 10-06-2021

I'm trying to add Cyrillic as well as a new line but it doesn't work

PHP Code:
/**
 * Alphanumeric, spaces, and a limited set of punctuation characters.
 * Accepted punctuation characters are: ~ tilde, ! exclamation,
 * # number, $ dollar, % percent, & ampersand, * asterisk, - dash,
 * _ underscore, + plus, = equals, | vertical bar, : colon, . period
 * ~ ! # $ % & * - _ + = | : .
 *
 * @param string $str
 *
 * @return boolean
 */
 
public function alpha_numeric_punct($str)
 {
 
// @see https://regex101.com/r/6N8dDY/1
 
return (bool) preg_match('/\A[А-Яа-яA-Z0-9 ~!#$%\&\*\-_+=|:.]+\z/i'$str);
 } 



RE: Help for alpha_numeric_punct - paulbalandan - 10-06-2021

Try this:
PHP Code:
return preg_match('/\A[\pL\pN ~!#$%\&\*\-_+=|:.]+\z/ui'$str) === 1