Last active
March 19, 2019 16:00
-
-
Save lord-alfred/7638d75d0cb2e2b05e714e2e90a7d3c7 to your computer and use it in GitHub Desktop.
Regular Expression For Special Characters & PHP Script For Get Special Characters Ranges
This file contains 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
[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E] |
This file contains 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 | |
$ranges = [ | |
['21', '2F'], | |
['3A', '40'], | |
['5B', '60'], | |
['7B', '7E'], | |
]; | |
$regexp_symbols = []; | |
foreach($ranges as $range) { | |
$start = $range[0]; | |
$end = $range[1]; | |
$symbols_map = '\x' . $start . '-\x' . $end; | |
echo $symbols_map . ': '; | |
$start = hexdec($start); | |
$end = hexdec($end); | |
for ($i = $start; $i <= $end; $i++) { | |
echo hex2bin(dechex($i)); | |
} | |
echo PHP_EOL; | |
$regexp_symbols[] = $symbols_map; | |
} | |
echo PHP_EOL . 'Regexp For Special Characters: [' . implode('', $regexp_symbols) . ']' . PHP_EOL; |
Author
lord-alfred
commented
Mar 19, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment