Untitled

 avatar
unknown
plain_text
a year ago
1.0 kB
8
Indexable
import os
import re

def process_war_files(directory):
    unique_strings = set()
    
    # Compile regex patterns
    pattern1 = re.compile(r'<(.*?)>')
    pattern2 = re.compile(r'\[(.*?)\]')
    
    # Iterate through files in the directory
    for filename in os.listdir(directory):
        if filename.endswith('.war'):
            file_path = os.path.join(directory, filename)
            
            with open(file_path, 'r', encoding='utf-8') as file:
                content = file.read()
                
                # Find all matches for both patterns
                matches1 = pattern1.findall(content)
                matches2 = pattern2.findall(content)
                
                # Add matches to the set
                unique_strings.update(matches1)
                unique_strings.update(matches2)
    
    return unique_strings

# Example usage
directory_path = '/path/to/your/directory'
result = process_war_files(directory_path)

print("Unique strings found:")
for string in result:
    print(string)
Editor is loading...
Leave a Comment