CodeIgniter Forums
Help for alpha_numeric_punct - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Help for alpha_numeric_punct (/thread-80253.html)



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