Sort by

recency

|

386 Discussions

|

  • + 0 comments
    import re
    
    for i in range(int(input())):
        s = input()
        matches = re.findall(r"[.:\s](#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3})", s)
        if matches:
            print(*matches, sep="\n")
    
  • + 0 comments
    import re
    p1 = r'{[^{}]*}'
    p2 = r'#[\da-fA-F]{3,6}'
    t = ''.join(input() for _ in range(int(input())))
    t = ''.join(re.findall(p1, t))
    print('\n'.join(re.findall(p2, t)))
    
  • + 0 comments

    None of the regex patterns I see here will exclude #BED and #Cab. Am I missing something?

    This is how I did it

    pattern = r'(?<!^)#[0-9A-Fa-f]{3,6}'

  • + 0 comments

    import re N = int(input()) for _ in range(N): inp = input() m = re.search(r"^#[A-Fa-f0-9]*", inp) if not m: t = re.findall(r"#[A-Fa-f0-9]{6}|#[A-Fa-f0-9]{3}", inp) if t!=[]: print(*t, sep="\n")

  • + 0 comments
    import re
    css = [input().strip() for _ in range(int(input()))]
    colors = [re.findall(r'#([\dA-F]{6}|[\dA-F]{3})(?=.*;)',line,re.IGNORECASE) for line in css]
    [print(f"#{hx}") for group in colors for hx in group]