#C14907. Valid US Phone Number Format Checker

    ID: 44608 Type: Default 1000ms 256MiB

Valid US Phone Number Format Checker

Valid US Phone Number Format Checker

Given a phone number as input, your task is to determine whether it is in one of the two valid US formats:

  • (xxx) xxx-xxxx
  • xxx-xxx-xxxx

Here, each x represents a digit (0-9). The phone number must match exactly one of these formats. Any deviation (such as missing digits, extra spaces, or other characters) should be considered invalid.

The regular expression to check the valid phone number format can be represented in LaTeX as follows:

$$ \texttt{^(\\(\\d\{3\}\\) \\d\{3\}-\\d\{4\}|\\d\{3\}-\\d\{3\}-\\d\{4\})$} $$

inputFormat

The input consists of a single line, containing the phone number string.

You should read from standard input.

outputFormat

Output a single line: True if the phone number matches one of the valid US formats or False otherwise. Write the output to standard output.

## sample
(123) 456-7890
True