From: "Shot (Piotr Szotkowski)" Date: 2009-09-02T20:18:58+09:00 Subject: Re: Best Practice for Multiline Regexps --U+BazGySraz5kW0T Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Lance Pollard: > 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... The only advantage of 1) over 2) is that if you have a situation where a combination of pattern 18 with file X breaks (because the pattern didn=E2=80=99t foresee some peculiar corner case which manifests only in fi= le X), then =E2=80=93 assuming you take snapshots of the operation after every pattern replace is over =E2=80=93 the first approach will let you keep the = work done by the first 17 pattern replacements and re-run the process from pattern 18 on, while the second approach will mean you have to roll back everything and redo all of the work that succeeded one time already. It really depends on the number of patterns, the number of files and whether you need IO/time efficiency or not. :) =E2=80=94 Shot --=20 I shot the spammer, but I didn=E2=80=99t kill the marketing. [elpanda] --U+BazGySraz5kW0T Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqeVJ0ACgkQi/mCfdEo8UpRBACgqe06Kwa7JgEGenFxxucsocGm XO0An3WuU266cMyb5ae+vDliUV9ipMa/ =cDTk -----END PGP SIGNATURE----- --U+BazGySraz5kW0T--