Skip to content

Commit

Permalink
Regex and Parsing!
Browse files Browse the repository at this point in the history
  • Loading branch information
snehalmastud authored Feb 23, 2020
1 parent dea747c commit ac2391c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Regex and Parsing/Hex Color Code/Solution.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit ac2391c

Please sign in to comment.