Menu
Coddy logo textTech

Wildcard Matching

Lesson 15 of 15 in Coddy's Recursion Challenges - Master The Recursive Thinking course.

challenge icon

Challenge

Hard

Write a function named test that gets a string s and a pattern p and returns true if the pattern matches the string, otherwise false.

The pattern can contain letters, numbers, white spaces and the following wildcards,

  • * - match any sequence of letters, numbers and white spaces.
  • . - match exactly one letter, number or white space.
  • ? - optionally match any sequence of letters, numbers and white spaces.

Examples,

  • test("My name is Jake", "My name is *")  ->  true
  • test("My name is Jake", "Your name is *")  ->  false
  • test("Maximum", "M..imum")  ->  true 
  • test("Mimum", "M?imum")  ->  true 
  • test("Minimum", "K?imum")  ->  false 

The pattern must match all the string, not partial substring!

Try it yourself

int test(char* s, char* p) {
    // Write code here
}

All lessons in Recursion Challenges - Master The Recursive Thinking