L
Lance Pollard
Hey,
What is the recommended way to parse a tree of files and replace
multiline pattern-matches, if you have say 20 regular expressions you're
looking for. I understand how to traverse directories, read/write
files, and use complex regular expressions, but the question is, what's
the optimal/recommended way to parse files (find/replace "def
method_name ...(some lines)... end", with some string, for instance)?
Is it:
1) Read file to String, match string against first pattern, read next
file into String, match with same pattern... once I've gone through all
the files with the first pattern, start over with the next pattern.
2) Read file to String, match whole string against all 20 patterns, go
to next file, match against 20 patterns...
3) Read file to String, match each line by 20 patterns...
4) Something with a Tokenizer which I don't yet understand (if so, could
you shed some light on it for me )
I basically want to write a few patterns to replace multiline text
patterns in lots of files, and need a consistent/fast way to do it in
ruby, without learning C or anything.
Thanks so much for the help,
Lance
What is the recommended way to parse a tree of files and replace
multiline pattern-matches, if you have say 20 regular expressions you're
looking for. I understand how to traverse directories, read/write
files, and use complex regular expressions, but the question is, what's
the optimal/recommended way to parse files (find/replace "def
method_name ...(some lines)... end", with some string, for instance)?
Is it:
1) Read file to String, match string against first pattern, read next
file into String, match with same pattern... once I've gone through all
the files with the first pattern, start over with the next pattern.
2) Read file to String, match whole string against all 20 patterns, go
to next file, match against 20 patterns...
3) Read file to String, match each line by 20 patterns...
4) Something with a Tokenizer which I don't yet understand (if so, could
you shed some light on it for me )
I basically want to write a few patterns to replace multiline text
patterns in lots of files, and need a consistent/fast way to do it in
ruby, without learning C or anything.
Thanks so much for the help,
Lance