D (PCRE_DOLLAR_ENDONLY) If this modifier is set, a dollar metacharacter in the pattern matches only at the end of the subject string. Without this modifier, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines). This modifier is ignored if m modifier is set. There is no equivalent to this modifier in Perl."$" 默认是匹配换行符的.<?php $str = "h2222222222\n"; $preg ="/^h\d+$/isD"; preg_match($preg,$str,$arr); var_dump($arr);
If this modifier is set, a dollar metacharacter in the pattern matches only at the end of the subject string. Without this modifier, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines). This modifier is ignored if m modifier is set. There is no equivalent to this modifier in Perl."$" 默认是匹配换行符的.<?php
$str = "h2222222222\n";
$preg ="/^h\d+$/isD";
preg_match($preg,$str,$arr);
var_dump($arr);