Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Regex Matching With Wildcards

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Regex Matching With Wildcards. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Confluent Cloud tooling can use wildcard filters when selecting resource names for event-routing or monitoring operations. Given a string and a pattern, determine whether the entire string matches the entire pattern.

The pattern supports two wildcard characters:

  • ? matches exactly one character.
  • * matches zero or more characters.
  • Any other character matches only the identical character.

Matching is case-sensitive, and the pattern must consume the complete string. Return True when the pattern matches and False otherwise.

Formal Specification

Implement wildcard_match(s, pattern).

  • Input: two strings, s and pattern.
  • Output: a boolean indicating whether the complete string matches the complete pattern.

Constraints

  • 0 <= len(s), len(pattern) <= 10^5
  • Strings contain printable ASCII characters
  • The pattern may contain any number of ? and * characters
  • Matching is case-sensitive
  • The entire string and pattern must match

Function Signature

def wildcard_match(s, pattern):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output