The PCRE-compliant PCRE_DOLLAR_ENDONLY modifier that makes the $
anchor match at the very end of the string (excluding the position before the final newline in the string).
/^\d+$/D
is equal to
/^\d+\z/
and matches a whole string that consists of 1 or more digits and will not match "123\n"
, but will match "123"
.