From ac2391cd31e200b825ddcae23d267baeb9b8ed0a Mon Sep 17 00:00:00 2001 From: Snehal Mastud <45584726+snehalmastud@users.noreply.github.com> Date: Sun, 23 Feb 2020 12:20:40 +0530 Subject: [PATCH] Regex and Parsing! --- Regex and Parsing/Hex Color Code/Solution.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Regex and Parsing/Hex Color Code/Solution.py diff --git a/Regex and Parsing/Hex Color Code/Solution.py b/Regex and Parsing/Hex Color Code/Solution.py new file mode 100644 index 0000000..6f78cbf --- /dev/null +++ b/Regex and Parsing/Hex Color Code/Solution.py @@ -0,0 +1,14 @@ +import sys,re +if sys.version_info[0]>=3: raw_input=input +inside_css=False +for _ in range(int(raw_input())): + s=raw_input().strip() + if not s: + pass + elif s[-1]=='{': + inside_css=True + elif s[-1]=='}': + inside_css=False + elif inside_css: + for e in re.finditer(r'#[0-9a-fA-F]+',s): + if len(e.group(0))==4 or len(e.group(0))==7: print(e.group(0))