Re: Regex replace help

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

 



On 12/04/2011 04:00 AM, Miloslav Trmač wrote:
> On Sun, Dec 4, 2011 at 12:07 AM, Richard Shaw <hobbes1069@xxxxxxxxx> wrote:
>> $ echo "const int TIXML_MAJOR_VERSION = 2;" | sed 's/const int
>> TIXML_MAJOR_VERSION = \([0-9]+\).*/\1/'
>> const int TIXML_MAJOR_VERSION = 2;
> 
> By replacing (sed 's/../../') with (sed -n 's/../../p') you can see
> that the regex doesn't match.  The cause is that sed recognizes an
> "\+" operator, not "+" operator.

...and if you want portability, don't use + or \+ with sed at all to
mean "one or more", use \{1,\} instead.
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux