What is the output when the regular expression s/[ABC] [abc]/xx/ is applied to the following string? ABCabc
A. ABxxbc
B. xxCxxc
C. xxxxxx
D. ABCabc
E. Axxaxx
What is the output when the regular expression s/[ABC] [abc]/xx/ is applied to the following string? ABCabc
A. ABxxbc
B. xxCxxc
C. xxxxxx
D. ABCabc
E. Axxaxx
echo “ABCabc” | sed ‘s/[ABC] [abc]/xx/’
ABCabc
Ans: D
echo ABCabc |sed s/[ABC][abc]/xx/ -> ABxxbc
[ABC][abc] = Aa Ab Ac Ba Bb Bc Ca Cb Cc
only Ca is a part of the string “ABCabc”
The correct Answer is A
The answer is A.
Only at the part Ca matches the argument and perform substitution.
if in s/[ABC] [abc]/xx/ there is a space, the answer is D, if there is no space between [ABC] [abc] the answer is A.
If there is a space between [ABC] [abc], an error message is displayed.
echo ABCabc | sed ‘s/[ABC] [abc]/xx/’
ABCabc
correct. But what is the logic in it ?