Last active
August 29, 2015 14:03
-
-
Save gilfernandes/aa00db055092355ba346 to your computer and use it in GitHub Desktop.
Extract regex patterns from multiple files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All the files from which the text is to be extracted | |
allFiles = ["MTMImportAll.txt", "ExportAll.txt"] | |
# Start looping | |
for fName in allFiles | |
# Open the file and read everything | |
f = open("src/test/resources/$fName") | |
println("******* Processing $f ****************") | |
array = readlines(f) | |
close(f) | |
# End reading file | |
# Create a set | |
uniques = Set() | |
# Starting to process the lines in the file | |
for line in array | |
# Extract in case of a match the process name from expressions like e.g: | |
# PROCESS : "RDPR", | |
# PROCESS : "MTM_BIZTYPEImport", | |
m = match(r"^\s*(?:PROCESS\s*\:\s*\"(.+?)(_RP1|Import)?\")", line) | |
if m != nothing | |
# Push the found string into the uniques set | |
push!(uniques, m.captures[1]) | |
end | |
end | |
# Print the unique extracted expressions | |
for unique in uniques | |
println(unique) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment