← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Technical phone screen for a software engineer role at eBay. One regex question, pretty focused, not a lot of back-and-forth beyond that.

Questions Asked (1)

Q1

Write a regular expression that matches valid US phone numbers with 10 digits, where the area code can optionally be in parentheses and digits may be separated by hyphens or other delimiters. How many distinct valid formats does your regex accept?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The regex part itself wasn't too bad but the follow-up about counting distinct valid formats is where I started fumbling.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the exact set of valid formats and delimiters with the interviewer, then build the regex incrementally, testing each component. Finally, count the distinct formats your regex accepts and discuss any trade-offs between strictness and flexibility.

Pro tip: Demonstrate awareness of edge cases like optional parentheses, multiple delimiter types, and the ambiguity of 'other delimiters'—ask clarifying questions to avoid over-engineering. Also, mention that counting distinct formats depends on how you define 'format' (e.g., delimiter choices and optional components).

1. Clarify requirements

Ask the interviewer to specify allowed delimiters (hyphens, spaces, dots?), whether parentheses are only around area code, and if extensions are allowed. This prevents assumptions that could lead to an incorrect regex.

2. Design regex incrementally

Build the regex piece by piece: start with area code (optional parentheses), then central office code, then line number, allowing delimiters between groups. Use non-capturing groups and character classes for delimiters.

3. Test with examples

Mentally or verbally test the regex against valid and invalid phone numbers to ensure it matches only the intended formats. Mention using tools like regex101 for verification.

4. Count distinct formats

Enumerate the combinations of optional parentheses and delimiter choices to determine how many distinct valid formats the regex accepts. Explain your counting method clearly.

5. Discuss trade-offs

Talk about the balance between flexibility and strictness, and how the regex might be adjusted for different use cases (e.g., international numbers).

Key Points to Mention

  • Use of non-capturing groups (?:...) for optional parts and delimiters.
  • Character class for delimiters, e.g., [-. ] to allow hyphens, dots, or spaces.
  • Anchors (^ and $) to ensure the entire string matches.
  • Optional parentheses around area code: \(?\d{3}\)?
  • Escaping special characters like parentheses and hyphens.
  • Counting distinct formats: consider each delimiter position and optional parentheses as independent choices.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.