matching escape string , doesn't work ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

matching escape string , doesn't work ?

aaron.lewis1989 (Bugzilla)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
        echo %A3 | sed 's/(%[0-9A-Z]{2})//g'

        I'd like %A3 like string to be removed , what's wrong with my script ?

        Thanks.


- --
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwxtVUACgkQvf41sEptMqBg9ACgmtDhFkoY14LS+oyRhDmdAcaw
6yAAoJvE0PW+UyayxG6+ZQtPABULpKkn
=L8MU
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: matching escape string , doesn't work ?

Bret S. Lambert-2
On Mon, Jul 05, 2010 at 06:35:01PM +0800, Aaron Lewis wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
> echo %A3 | sed 's/(%[0-9A-Z]{2})//g'
>
> I'd like %A3 like string to be removed , what's wrong with my script ?
>

According to the sed manpage, it doesn't use {} in this way; you seem
to be using the wrong syntax (although sed veterans can likely give a
more thorough answer).

try sed 's/%[0-9A-Z][0-9A-Z]//g' (minus any typos/thinkos on my part)

> Thanks.
>
>
> - --
> Best Regards,
> Aaron Lewis - PGP: 0x4A6D32A0
> FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
> irc: A4r0n on freenode
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkwxtVUACgkQvf41sEptMqBg9ACgmtDhFkoY14LS+oyRhDmdAcaw
> 6yAAoJvE0PW+UyayxG6+ZQtPABULpKkn
> =L8MU
> -----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

[SOLVED] Re: matching escape string , doesn't work ?

aaron.lewis1989 (Bugzilla)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/05/2010 06:42 PM, Bret S. Lambert wrote:
> sed 's/%[0-9A-Z][0-9A-Z]//g'

Thanks , and same for VIM.

- --
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwxu2cACgkQvf41sEptMqBcKQCeORAzcjXuLpHtgZNvBXLzDVvA
nFkAn3Dw3r7YUocmDiax4Z5AIQm/hQQu
=4fFn
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: matching escape string , doesn't work ?

William Boshuck
In reply to this post by Bret S. Lambert-2
On Mon, Jul 05, 2010 at 12:42:51PM +0200, Bret S. Lambert wrote:

> On Mon, Jul 05, 2010 at 06:35:01PM +0800, Aaron Lewis wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi,
> > echo %A3 | sed 's/(%[0-9A-Z]{2})//g'
> >
> > I'd like %A3 like string to be removed , what's wrong with my script ?
> >
>
> According to the sed manpage, it doesn't use {} in this way; you seem
> to be using the wrong syntax (although sed veterans can likely give a
> more thorough answer).
>
> try sed 's/%[0-9A-Z][0-9A-Z]//g' (minus any typos/thinkos on my part)

sed(1) uses basic regular expressions (see re_format(7) for
details).  In particular, you should prepend with a backslash
the parentheses and braces in the original example, although
the parentheses are superfluous for the stated purpose.  If
you want to use bounds, then

echo %A3 | sed 's/%[0-9A-Z]\{2\}//g'

will do.

Reply | Threaded
Open this post in threaded view
|

Re: matching escape string , doesn't work ?

Otto Moerbeek
In reply to this post by aaron.lewis1989 (Bugzilla)
On Mon, Jul 05, 2010 at 06:35:01PM +0800, Aaron Lewis wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
> echo %A3 | sed 's/(%[0-9A-Z]{2})//g'
>
> I'd like %A3 like string to be removed , what's wrong with my script ?

sed uses basic re's by default. Gnu sed implements { } by default as
an extensiomn to Posix, we do not. use -E.


        -Otto

Reply | Threaded
Open this post in threaded view
|

[SOLVED] Re: matching escape string , doesn't work ?

aaron.lewis1989 (Bugzilla)
In reply to this post by William Boshuck
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/05/2010 07:18 PM, William Boshuck wrote:

> On Mon, Jul 05, 2010 at 12:42:51PM +0200, Bret S. Lambert wrote:
>> On Mon, Jul 05, 2010 at 06:35:01PM +0800, Aaron Lewis wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Hi,
>>> echo %A3 | sed 's/(%[0-9A-Z]{2})//g'
>>>
>>> I'd like %A3 like string to be removed , what's wrong with my script ?
>>>
>>
>> According to the sed manpage, it doesn't use {} in this way; you seem
>> to be using the wrong syntax (although sed veterans can likely give a
>> more thorough answer).
>>
>> try sed 's/%[0-9A-Z][0-9A-Z]//g' (minus any typos/thinkos on my part)
>
> sed(1) uses basic regular expressions (see re_format(7) for
> details).  In particular, you should prepend with a backslash
> the parentheses and braces in the original example, although
> the parentheses are superfluous for the stated purpose.  If
> you want to use bounds, then
>
> echo %A3 | sed 's/%[0-9A-Z]\{2\}//g'
>
> will do.

Yep , should escape it , that's the problem


- --
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwx5K8ACgkQvf41sEptMqDTkgCgmg76T5ahKdsuA6WGCfulXoT1
s+sAoJ2ByK3CpUMkv8N1sHbrKIoddxpA
=bmJF
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

[SOLVED] Re: matching escape string , doesn't work ?

aaron.lewis1989 (Bugzilla)
In reply to this post by Otto Moerbeek
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/05/2010 07:18 PM, Otto Moerbeek wrote:

> On Mon, Jul 05, 2010 at 06:35:01PM +0800, Aaron Lewis wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi,
>> echo %A3 | sed 's/(%[0-9A-Z]{2})//g'
>>
>> I'd like %A3 like string to be removed , what's wrong with my script ?
>
> sed uses basic re's by default. Gnu sed implements { } by default as
> an extensiomn to Posix, we do not. use -E.
>
>
> -Otto

Understand , i'd notice it.


- --
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwx5OcACgkQvf41sEptMqCsZACfdlULMONFiPuzAWcM9EiPYNtd
lXEAoLKCQ65ZjAaSXoqXjnAMiWPmOwyG
=4pJ4
-----END PGP SIGNATURE-----