Last active
June 12, 2018 04:47
-
-
Save teimur8/535c5475a08ff3d48c18c68fed439664 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://dreamhelg.ru/2010/02/15-regular-expression-for-web-developers/ | |
| foo Строка “foo” | |
| ^foo Строка начинается с “foo” | |
| foo$ Строка заканчивается на “foo” | |
| ^foo$ «foo» встречается в строке только один раз | |
| [abc] a, b, или c | |
| [a-z] любой символ в нижнем регистре | |
| [^A-Z] любой символ, не находящийся в верхнем регистре | |
| (gif|jpg) Означает как «gif” так и “jpeg” | |
| [a-z]+ Один или более символов нижнего регистра | |
| [0-9.-] Любая цифра, точка или знак минус | |
| ^[a-zA-Z0-9_]{1,}$ Любое слово, хотя бы одна буква, число или _ | |
| ([wx])([yz]) wy, wz, xy, или xz | |
| (^A-Za-z0-9) Любой символ (не число и не буква) | |
| ([A-Z]{3}|[0-9]{4}) Означает три буквы или 4 цифры | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $vin = preg_match("/^[A-Za-z0-9]{17}$/", $code); // 17 символов | |
| $frame = preg_match("/^[A-Za-z0-9]+[-][0-9]{6,7}$/", $code); // цифры и буквы потом тире потом 6 или 7 цифр | |
| // https://htmlweb.ru/php/php_regexp.php | |
| preg_replace("/[^0-9]/", "", "1 23"); // 123 | |
| // удаляем скобки и все что внутри | |
| preg_replace("#\(.*?\)#", "", $item1['post']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment