tidy some regex

This commit is contained in:
Ben Harris 2022-09-29 11:15:07 -04:00
parent 1847394cfb
commit c7a0edd91c
3 changed files with 6 additions and 6 deletions

View File

@ -3107,7 +3107,7 @@ abstract class Net_DNS2_RR
// //
// //
$values = preg_split('/[\s]+/', $line); $values = preg_split('/\s+/', $line);
if (count($values) < 3) { if (count($values) < 3) {
throw new Net_DNS2_Exception( throw new Net_DNS2_Exception(
@ -4404,7 +4404,7 @@ class Net_DNS2_RR_APL extends Net_DNS2_RR
{ {
foreach ($rdata as $item) { foreach ($rdata as $item) {
if (preg_match('/^(!?)([1|2])\:([^\/]*)\/([0-9]{1,3})$/', $item, $m)) { if (preg_match('/^(!?)([1|2]):([^\/]*)\/([0-9]{1,3})$/', $item, $m)) {
$i = array( $i = array(
@ -6265,8 +6265,8 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
// //
$res = preg_match( $res = preg_match(
'/^(\d+) \s+((\d+) \s+)?(([\d.]+) \s+)?(N|S) \s+(\d+) ' . '/^(\d+) \s+((\d+) \s+)?(([\d.]+) \s+)?([NS]) \s+(\d+) ' .
'\s+((\d+) \s+)?(([\d.]+) \s+)?(E|W) \s+(-?[\d.]+) m?(\s+ ' . '\s+((\d+) \s+)?(([\d.]+) \s+)?([EW]) \s+(-?[\d.]+) m?(\s+ ' .
'([\d.]+) m?)?(\s+ ([\d.]+) m?)?(\s+ ([\d.]+) m?)?/ix', '([\d.]+) m?)?(\s+ ([\d.]+) m?)?(\s+ ([\d.]+) m?)?/ix',
implode(' ', $rdata), $x implode(' ', $rdata), $x
); );

View File

@ -14,7 +14,7 @@
// Reduce dependencies. Duplicates code though. // Reduce dependencies. Duplicates code though.
private static function FilenameSafe($filename) private static function FilenameSafe($filename)
{ {
return preg_replace('/[_]+/', "_", preg_replace('/[^A-Za-z0-9_.\-]/', "_", $filename)); return preg_replace('/_+/', "_", preg_replace('/[^A-Za-z0-9_.\-]/', "_", $filename));
} }
private static function ReplaceNewlines($replacewith, $data) private static function ReplaceNewlines($replacewith, $data)

View File

@ -192,7 +192,7 @@
// Converts UTF8 characters in a string to HTML entities. // Converts UTF8 characters in a string to HTML entities.
public static function ConvertToHTML($data) public static function ConvertToHTML($data)
{ {
return preg_replace_callback('/([\xC0-\xF7]{1,1}[\x80-\xBF]+)/', 'UTF8::ConvertToHTML__Callback', $data); return preg_replace_callback('/([\xC0-\xF7][\x80-\xBF]+)/', 'UTF8::ConvertToHTML__Callback', $data);
} }
private static function ConvertToHTML__Callback($data) private static function ConvertToHTML__Callback($data)