6 kyu

regex pattern to check if string has all characters

405 of 918albertogcmr

Description:

Task:

Your function should return a valid regular expression. This is a pattern which is normally used to match parts of a string. In this case will be used to check if all the characters given in the input appear in a string.

Input

Non empty string of unique alphabet characters upper and lower case.

Output

Regular expression pattern string.

Examples

Your function should return a string.

# Function example
def regex_contains_all(st): 
  return r"abc"
function regexContainsAll(str) {
  return "abc";
}
def regex_contains_all(s)
  "abc"
end
public static String regexContainsAll(str) {
  return "abc";
}

That regex pattern will be tested like this.

# Test
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}") -> True
const abc = "abc";
const pattern = regexContainsAll(abc);
const str = "zzzaaacccbbbzzz";
new RegExp(pattern).test(str);  // -> true
abc = "abc"
pattern = regex_contains_all(abc)
str = "zzzaaacccbbbzzz"
/#{pattern}/ === str # -> true
String abc = "abc";
String pattern = regexContainsAll(abc);
String str = "zzzaaacccbbbzzz";
Pattern.compile(pattern).matcher(str).find();  // -> true
Regular Expressions
Fundamentals
Strings

Stats:

CreatedFeb 20, 2020
PublishedApr 3, 2020
Warriors Trained3230
Total Skips97
Total Code Submissions6113
Total Times Completed918
Python Completions405
JavaScript Completions347
Java Completions162
Ruby Completions53
Total Stars57
% of votes with a positive feedback rating88% of 213
Total "Very Satisfied" Votes174
Total "Somewhat Satisfied" Votes29
Total "Not Satisfied" Votes10
Total Rank Assessments20
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • albertogcmr Avatar
  • B1ts Avatar
  • Madjosz Avatar
  • user8436785 Avatar
  • Just4FunCoder Avatar
Ad