LPIC-1 Exam 101 v5 (Linux Administrator) — Question 6
What is the output when the regular expression s/[ABC] [abc]/xx/ is applied to the following string?
ABCabc -
Answer options
- A. ABxxbc
- B. xxCxxc
- C. xxxxxx
- D. ABCabc
- E. Axxaxx
Correct answer: A
Explanation
The correct answer is A because the regular expression matches the pattern where a character from [ABC] is followed by a space and then a character from [abc]. In the string 'ABCabc', the first match is 'A b', which gets replaced by 'xx', resulting in 'ABxxbc'. The other options do not match the specified pattern or do not reflect the changes accurately.