Regular Expressions 101

Community Patterns

PSR-16 Cache Key

1

Regular Expression
PCRE (PHP <7.3)

/
^[a-zA-Z0-9_.]{1,64}$
/
g

Description

https://www.php-fig.org/psr/psr-16/

Key - A string of at least one character that uniquely identifies a cached item. Implementing libraries MUST support keys consisting of the characters A-Z, a-z, 0-9, _, and . in any order in UTF-8 encoding and a length of up to 64 characters. Implementing libraries MAY support additional characters and encodings or longer lengths, but MUST support at least that minimum. Libraries are responsible for their own escaping of key strings as appropriate, but MUST be able to return the original unmodified key string. The following characters are reserved for future extensions and MUST NOT be supported by implementing libraries: {}()/@:

Submitted by anonymous - 3 years ago