From: "Esteban Manchado Velázquez" Date: 2006-08-01T00:38:25+09:00 Subject: Re: Howto Delete 3 Leftmost Characters --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 31, 2006 at 07:25:04AM +0900, Skeets wrote: > > also, i believe the regex Esteban gave will get rid of all white spaces > > - both to the left and right of the ip address. >=20 > actually, this isn't true so i still have to use the strip method. >=20 > i have some regex experience - but not too much. >=20 > i pretty much take some pain killers and then try and figure out what i > need as the need arises. ;-) >=20 > i'll bet this regex can be update to remove all spaces, however, i will > have to look into that next week. Something like: s =3D "#ip 127.0.0.1 " s.sub(/^#ip\s+(.+?)\s*$/, '\1') That's way uglier, because you have to match the whole line and then substitute everything for the first parens contents.... _and_ you have to u= se ".+?" instead of simply ".+" inside them, or otherwise you will get everyth= ing until the end of the line :-/ The "?" after "*" or "+" means non-greediness, BTW. --=20 Esteban Manchado Vel=E1zquez - http://www.foton.es EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es --k+w/mQv8wyuph6w0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFEziPfhYgK5b1UDsERAohiAJ9bMlzyZJma2fdf0MbXh0IKypuh1gCfUqGr Cq9eDHOvO7La5Ur52CHYDYM= =ho+Q -----END PGP SIGNATURE----- --k+w/mQv8wyuph6w0--