Answers for "Code Using Only Regex To find HTML Files"

0

Code Using Only Regex To find HTML Files

import re
import os
currentdir = os.getcwd()
files = os.listdir(currentdir)
pattern = "^.*html$"
prog = re.compile(pattern)
htmlfiles=[]
for file in files:
    result = prog.findall(file)
    if len(result)!=0:
        htmlfiles.append(result[0])

for htmlfile in htmlfiles:
    print(htmlfile)
Posted by: Guest on August-08-2021

Code answers related to "Code Using Only Regex To find HTML Files"

Browse Popular Code Answers by Language