[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56018: sed bug when using extended regular expressions and [] with b
From: |
Bob Power |
Subject: |
bug#56018: sed bug when using extended regular expressions and [] with backslash character class identifiers. |
Date: |
Thu, 16 Jun 2022 10:42:55 +0000 (UTC) |
# sed --version
sed (GNU sed) 4.5
Copyright (C) 2018 Free Software Foundation, Inc.
Given
\s = whitespace, [\s] should also be a whitespace.
We should get the same results if we use [\s] in place of \s
but we don't...
test 1: replace all whitespace sequences with xx using \s - OK/Works as
expected;
echo 'A BC D' | sed -E 's/\s+/xx/g'
AxxBCxxD
test 2: replace all whitespace sequences with xx using [\s] - fails/not as
expected - should be same as test 1 output;
echo 'A BC C' | sed -E 's/[\s]+/xx/g'
A BC C
After some experimenting it seems that inside [] sed sees all \ as literal \
characters and not part of class identifiers..
echo 'A B\C Csstt' | sed -E 's/[\s]+/xx/g'
A BxxC Cxxtt
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#56018: sed bug when using extended regular expressions and [] with backslash character class identifiers.,
Bob Power <=