#C13397. Contact Information Extraction

    ID: 42930 Type: Default 1000ms 256MiB

Contact Information Extraction

Contact Information Extraction

Given a multi-line string representing contact information, extract valid entries containing a full name, an email address, and a phone number. Each input line consists of three fields separated by semicolons.

The email address must match the pattern \(\texttt{[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}}\) and the phone number must be in one of the following formats: \(\texttt{(123) 456-7890}\) or \(\texttt{123-456-7890}\). Only lines where both email and phone match the respective patterns are considered valid. The output is a JSON object mapping names to their corresponding contact details.

inputFormat

The input is read from stdin and consists of multiple lines. Each line contains three fields separated by semicolons in the following order: name, email, and phone.

outputFormat

The output should be printed to stdout as a JSON object. Each key in the JSON object is a name from a valid input line, and its value is an object with two keys: email and phone, containing the corresponding contact details.

## sample
Alice Johnson; alice.j@example.com; (123) 456-7890
{"Alice Johnson": {"email": "alice.j@example.com", "phone": "(123) 456-7890"}}