Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Regular Expressions Module 10

Validation patterns and their limits interview questions

Interview questions on validation patterns and their limits: warm-ups, then what each harder question tests and how a good answer starts.

7 questions: 3 warm-ups and 4 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    Why must a validator match the whole input, and how do the anchors differ by engine?

    Answered in the lesson Validating formats: numbers, IDs and dates

  2. Fresher to mid

    Why is [0-9] safer than \d for an ID?

    Answered in the lesson Validating formats: numbers, IDs and dates

  3. Fresher to mid

    Why can no regular expression prove that an email address works?

    Answered in the lesson Emails, URLs and when to use a parser

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    A bank-details form takes an IFSC, a MICR code, an account number, a UK sort code (six digits) and a SWIFT code (eight or eleven characters). Each format comes from a different issuer. Design the validation layer: what runs where, how do you report an error that a user can act on, and what is the test plan?

    What it tests
    Reading each format from its own issuer, running whole-input anchors and a length cap first, choosing where existence checks run, and writing a differential test plan for every field.
    First step
    List the fields and name the issuer of each one. For each format write a short sentence of the rule, straight from the issuer's page, and underline the parts a pattern can express. The patterns are the first layer; name the second layer (a parser, a lookup) and where it runs.
    Follow-ups

    From the lesson Validating formats: numbers, IDs and dates

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 5 minutes
  2. Mid to senior

    A warehouse system accepts a product barcode and a batch date. A loss report shows that a scanner has sent invalid barcodes with the right shape and dates that no calendar has: the validator passed strings its downstream rejected. What was missing, and how do you fix it without changing the shape pattern?

    What it tests
    Separating the shape layer from the real check (a check digit and a calendar check), knowing which bugs each layer can catch, and designing a backfill for the strings the system already stored.
    First step
    Separate the two layers of the lesson. The barcode's shape is a regex; the real check is a GS1 check digit, a short loop. The date's shape is also a regex; the real check is datetime.date. Say which layer was missing in each case and where it belongs in the pipeline.
    Follow-ups

    From the lesson Validating formats: numbers, IDs and dates

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  3. Mid to senior

    After sign-in, a site sends the browser to the page named in a next parameter, and only the site's own pages may be targets. A Python service writes the Location header. How do you make its check and the browser agree on the target, and which inputs go into its tests?

    What it tests
    Seeing the browser as a second URL parser, resolving a relative target the way it does, comparing origins rather than strings, and building a test table from inputs that two parsers read differently.
    First step
    Name the two parsers first: the service's and the browser's. Then decide what a valid target may look like, such as a path on this site, say how it is turned into the URL the browser will follow, and say what must be equal before the header is written.
    Follow-ups

    From the lesson Emails, URLs and when to use a parser

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 5 minutes

All Regular Expressions interview questions · The Regular Expressions track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.