import re # Define the input and output file paths input_file_path = 'big_file.txt' output_file_path_accountgoogle = 'accountgoogle.txt' output_file_path_wordpress = 'wordpress.txt' # Define the patterns to match pattern_accountgoogle = re.compile(r'account\.google\.com') pattern_wordpress = re.compile(r'(wp-login\.php|\/wp-admin\/)') pattern_ignore = re.compile(r'(wordpress\.com|localhost|172\.169|[\x00-\x7F]+)') # ASCII characters # Open the input file and output files with open(input_file_path, 'r', encoding='utf-8') as input_file: with open(output_file_path_accountgoogle, 'w', encoding='utf-8') as output_file_accountgoogle: with open(output_file_path_wordpress, 'w', encoding='utf-8') as output_file_wordpress: for line in input_file: # Check if the line contains the pattern if pattern_accountgoogle.search(line): output_file_accountgoogle.write(line) elif pattern_wordpress.search(line) and not pattern_ignore.search(line): output_file_wordpress.write(line)