Regex modifiers (flags) – PCRE_DOLLAR_ENDONLY modifier

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".

if you want to reproduce, please indicate the source:
Regex modifiers (flags) – PCRE_DOLLAR_ENDONLY modifier - CodeDay