Welcome Guest, Not a member yet? Register   Sign In
Help for alpha_numeric_punct
#1

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);
 } 
Reply
#2

(This post was last modified: 10-06-2021, 06:47 PM by paulbalandan.)

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




Theme © iAndrew 2016 - Forum software by © MyBB