[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string manipulation : removing a part of a string

From: Eric Blake
Subject: Re: string manipulation : removing a part of a string
Date: Mon, 18 Jun 2012 09:49:13 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

On 06/18/2012 09:40 AM, Vincent Torri wrote:

>> But you can still be shorter than using a pushdef:
>> option=m4_bpatsubst([[$2]], [^-Wno-], [-W])
> does not work. Removing ^ seems to work

Oh, right.  That's due to the necessity of double-quoting $2 introducing
extra characters to be matched by the regex.  Omitting the anchor means
that you will match -Wno- wherever it appears (even in
-fsome-Wno-option); and if you are worried about that being a real
possibility, then you can restore the anchoring effect by taking into
account the double-qouting, and all without unbalancing [], by the use
of the . regex:

option=m4_bpatsubst([[$2]], [^\(.\)-Wno-], [\1-W])

But you are probably right that you don't have to worry about -Wno-
appearing anywhere but the beginning, in which case omitting the anchor
is indeed simplest.

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]