We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Regex and Parsing
- Hex Color Code
- Discussions
Hex Color Code
Hex Color Code
+ 0 comments lol
print("\n".join(re.findall(r"#[A-Fa-f0-9]{3}(?=;|,|\))|#[A-Fa-f0-9]{6}(?=;|,|\))", "\n".join([input() for _ in range(int(input()))]))))
+ 0 comments import re pattern = re.compile(r"(#[\da-f]{3}|#[\da-f]{6})(?=[;,)])", re.IGNORECASE) N = int(input()) ls = [input() for _ in range(N)] S = "\n".join(ls) if pattern.search(S): for match in re.findall(pattern, S): print(match)
+ 0 comments # Enter your code here. Read input from STDIN. Print output to STDOUT import re def hexfinder(css): blocks = re.findall(r'\{([^}]+)\}', css) pattern = r'#(?i:[0-9a-f]{6}|[0-9a-f]{3})' for block in blocks: matches = re.findall(pattern, block) for match in matches: print(match) if __name__ == '__main__': num_lines = int(input()) total_input = '\n'.join(input() for _ in range(num_lines)) hexfinder(total_input)
+ 0 comments import re pat = re.compile(r'(#[A-Fa-f0-9]{3}|#[A-Fa-f0-9]{6})\s*[,;)]') n = int(input()) for _ in range(n): css_color_codes = pat.findall(input()) if css_color_codes: print(*css_color_codes, sep='\n')
+ 1 comment import re p = re.compile(r"(#[abcdef0-9]{3,6})\S",re.I) for _ in range(int(input())): l = input() for m in p.findall(l): print(m)
Load more conversations
Sort 330 Discussions, By:
Please Login in order to post a comment