From: Chad Perrin Date: 2011-07-16T00:32:14+09:00 Subject: Re: replace string between xml tags that contains special characters --azLHFNyN32YCQGCU Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 15, 2011 at 07:41:17PM +0900, Rousan Malik wrote: > I am trying to get rid of the string in a xml file which contains some > special characters. I want it to be transformed from the following: >=20 > =DE=A2g%9B@I%E3%F6%FCp%AFX%BD%80%91%B5pEK%C9!j%D3%F3S=7FY%C3%F6B~%C8%FC > ^%87%C4%F2]! %B9%DF=3D%E7Y%B9element: > %F0wt^=CF=B6b%99%90%94%D4N%8D%FA%8A%EE%81_ > =DE=A2g%9B@I%E3%F6%FCp%AFX%BD%80%91%B5pEK%C9!j%D3%F3S=7FY%C3%F6B~%C8%FC > ^%87%C4%F2]! %B9%DF=3D%E7Y%B9" >=20 > to >=20 > >=20 > I tried using gsub() with regex but so far haven't been successful. It seems to me you should make use of the non-greedy modifier, which is ?, for .* to indicate you want to match any characters up to a particular matching string in this case. Why don't you share what you have for an attempt at a useful regex, then we can offer modifications to yours rather than just providing a complete solution from scratch? This page offers some information about special characters in regexen: http://www.zenspider.com/Languages/Ruby/QuickRef.html#12 The non-greedy modifier can be found easily by doing a text search on that page for "non-greedy". --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --azLHFNyN32YCQGCU Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk4gWZ8ACgkQ9mn/Pj01uKVQhwCdH9ZoiUOnZ4PsW1/+6O0fObdp lAcAoOH4E7XBRGo7aQlJ0tYgiMjwu7/n =7EHZ -----END PGP SIGNATURE----- --azLHFNyN32YCQGCU--