HackerRank-Python/Regex(14)
-
Prepare > Regex > Character Class > Matching Specific Characters
Matching Specific Characters | HackerRank Use the [ ] expression to match specific characters. www.hackerrank.com 문제 Task You have a test string S. Your task is to write a regex that will match S with following conditions: S must be of length: 6 First character: 1, 2 or 3 Second character: 1, 2 or 0 Third character: x, s or 0 Fourth character: 3, 0 , A or a Fifth character: x, s or u Sixth chara..
2023.10.25 -
Prepare > Regex > Introduction > Matching Start & End
Matching Start & End | HackerRank Use the ^ symbol to match the start of a string, and the $ symbol to match the end characters. www.hackerrank.com 문제 Task You have a test string S. Your task is to match the pattern Xxxxx. Here, x denotes a word character, and X denotes a digit. S must start with a digit X and end with . symbol. S should be 6 characters long only. 코드 Regex_Pattern = r"^\d\w{4}\...
2023.10.10 -
Prepare > Regex > Introduction > Matching Word & Non-Word Character
Matching Word & Non-Word Character | HackerRank Use \w to match any word and \W to match any non-word character. www.hackerrank.com 문제 Task You have a test string S. Your task is to match the pattern xxxXxxxxxxxxxxXxxx Here x denotes any word character and X denotes any non-word character. => xxxXxxxxxxxxxxXxxx구조를 S에서 찾아라. x는 알파벳과숫자, 언더바(_)이고 X는 그 외 모든 문자. 코드 Regex_Pattern = r"\w{3}\W\w{10}\W\w{..
2023.10.10 -
Prepare > Regex > Introduction > Matching Whitespace & Non-Whitespace Character
Matching Whitespace & Non-Whitespace Character | HackerRank Use \s to match whitespace and \S to match non whitespace characters in this challenge. www.hackerrank.com 문제 Task You have a test string S. Your task is to match the pattern XXxXXxXX Here, x denotes whitespace characters, and X denotes non-white space characters. Note This is a regex only challenge. You are not required to write code. ..
2023.10.09 -
Prepare > Regex > Introduction > Matching Digits & Non-Digit Characters
Matching Digits & Non-Digit Characters | HackerRank Use the expression \d to match digits and \D to match non-digit characters. www.hackerrank.com 문제 => "숫자 숫자 비숫자 숫자 숫자 비숫자 숫자 숫자" 패턴을 찾아라 코드 Regex_Pattern = r"\d{2}\D\d{2}\D\d{4}"# Do not delete 'r'. import re print(str(bool(re.search(Regex_Pattern, input()))).lower()) 노트 왜 안됨? Regex_Pattern = r"[\d{2}\D]{2}\d{4}"# Do not delete 'r'. import re p..
2023.10.07 -
Prepare > Regex > Introduction > Matching Anything But a Newline
Matching Anything But a Newline | HackerRank Use [.] in the regex expression to match anything but a newline character. www.hackerrank.com 문제 Task You have a test string S. Your task is to write a regular expression that matches only and exactly strings of form: abc.def.hki.xkj, where each variable a, b, c, d, e, f, h, k, i, j, k, x can be any single character except the newline. => 문자 3자리 와 .(점..
2023.10.06 -
Prepare > Regex > Introduction > Matching Specific String
문제 Task You have a test string . Your task is to match the string hackerrank. This is case sensitive. Note This is a regex only challenge. You are not required to write code. You only have to fill in the regex pattern in the blank (_________). => 빈칸에 정규표현식을 넣어, 문자열 S에 hackerrank 가 몇 번 나오는지 찾아라 코드 Regex_Pattern = r'hackerrank'# Do not delete 'r'. import re Test_String = input() match = re.findall..
2023.10.05