I have the following REGEX pattern: ~^(?!$)(?:(?\\d+)y)?(?:(?\\d+)m)?(?:(?\\d+)d)?$~.
~^(?!$)(?:(?\\d+)y)?(?:(?\\d+)m)?(?:(?\\d+)d)?$~
Testing it on https://regex101.com/