Implement a function that should return a valid regular expression. This is a pattern which is normally used to match parts of a string. In this case, it'll be used to check if all the characters given in the input appear in a string.
Your input will be a string of upper and lower case alphabetical characters. You should output a regex pattern as a string.
Example
abc = 'abc'
pattern = regex_contains_all(abc)
st = 'zzzaaacccbbbzzz'
bool(re.match(pattern, st), f"Testing if {st} contains all characters in {abc} with your pattern {pattern}")
will return True
Tests
abc = 'abc'
pattern = regex_contains_all(abc)
bool(re.match(pattern, 'bca'))
bool(re.match(pattern, 'baczzz'))
bool(re.match(pattern, 'ac'))
bool(re.match(pattern, 'cb'))
Good luck!
This challenge comes from albertogcmr on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!