Beta

BASH commands: Wildcards I

Description:

In BASH there's a simple, yet a powerful feature, called the wildcards. In this first iteration of the problem, we will tackle the most basic of all wildcards in BASH, - the question mark ? wildcard.

So when does this all get used? Whenever searching for a file, sometimes you might be interested in matching a set of files based on their name, for example given a list of files:

- aa.jpg
- ab.jpg
- ac.jpg
- za.jpg
- zb.jpg

We might be interested in selecting all the files starting with an a character, such as: aa.jpg, ab.jpg and ac.jpg. For this particular case, we would use: a?.jpg, to get the desired result.

The question mark wildcard ? is very similar in its behavior to the . in Regexp, that is, it matches any character as long as its there. For example, .? will match .a and ._, but not a and not .. This effectively implies that the pattern length should equal the length of the matched string.

The question mark wildcard ? can be used in a pattern as many times as necessary. For example, ?b?.gif or ???.elf or even ????.

Given a string pattern representing the pattern that may or may not contain wildcards, and a string filename, return a truthy value if the given pattern matches the filename, or a falsy value, if it doesn't.

If you have any questions and or suggestions regarding the task, please feel free to write in the discussions. Have fun!

Algorithms

Similar Kata:

Stats:

CreatedMay 30, 2017
PublishedMay 31, 2017
Warriors Trained104
Total Skips8
Total Code Submissions70
Total Times Completed39
C Completions39
Total Stars2
% of votes with a positive feedback rating89% of 27
Total "Very Satisfied" Votes21
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes0
Total Rank Assessments24
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • lilsweetcaligula Avatar
  • FArekkusu Avatar
Ad