From: Eero Saynatkari Date: 2006-10-12T02:42:24+09:00 Subject: Re: scanning strings, backward? --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2006.10.11 20:05, Bil Kleb wrote: > Hi, >=20 > I would like to automate a code cleanup task which involves > finding warning messages like, >=20 > Warning: ../../LibF90/bc_inviscid.f90, line 1707: > DT explicitly imported into BC_INVISCID_FLUX but not used > detected at BC_INVISCID_FLUX@ >=20 > and removing the offending unused import. >=20 > So, the tasks are roughly, >=20 > 1) Goto line 1707 of the file File.readlines for reasonably sized files, f.each_with_index for skipping over until 1707. > 2) Search backward until line.match /\Wdt\W/i > 3) Remove /dt/i Combine these by anchoring. line.sub /(.*\W)dt(\W.*)$/i, '\1\2' If the \W are spaces, strip one of them out. --opJtzjQTFsWo+cga Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFLSxu7Nh7RM4TrhIRAup3AKC0YZ1ja+tdjRJHnWFvIIbMw+u6rQCZAdJh EI8y0gWu7rZU+EYOP8mopQQ= =woQX -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--