File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,8 @@ public function parse(string $serialNumber): array
163163
164164 protected function formatToRegex (): string
165165 {
166+ $ format = preg_replace ('/([^\w\s])/i ' , '\\\\$1 ' , $ this ->format );
167+
166168 $ value = preg_replace_callback_array (
167169 [
168170 '/P+/ ' => fn ($ matches ) => ($ matches [0 ] && $ length = mb_strlen ($ matches [0 ])) ? "(?<prefix>[a-zA-Z]{ {$ length }}) " : '' ,
@@ -171,7 +173,7 @@ protected function formatToRegex(): string
171173 '/Y+/ ' => fn ($ matches ) => ($ matches [0 ] && $ length = mb_strlen ($ matches [0 ])) ? "(?<year>\d{ {$ length }}) " : '' ,
172174 '/C+/ ' => fn ($ matches ) => ($ matches [0 ] && $ length = mb_strlen ($ matches [0 ])) ? "(?<count>\d{ {$ length }}) " : '' ,
173175 ],
174- $ this -> format
176+ $ format
175177 );
176178
177179 return is_string ($ value ) ? $ value : '' ;
You can’t perform that action at this time.
0 commit comments