JS - Check if string contain only 0

javascript, regex

Solution

/^0*$/.test(subject)

returns `True` for a string that contains nothing but (any number of, including 0) zeroes. If you don't want the empty string to match, use `+` instead of `*`.

Problem

I have a data of day and I need to check if it contain only 0. How I can check if string contain only 0? I want to do it with regular expressions.

Original source