Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 101-500 topic 1 question 96 discussion

Actual exam question from LPI's 101-500
Question #: 96
Topic #: 1
[All 101-500 Questions]

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
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
cast7omadrid1
Highly Voted 4 years, 1 month ago
The correct answer is A -> ABxxbc. You have to try it inside a file, open it with vim and do :s/[ABC] [abc]/xx/
upvoted 26 times
luismonge
1 week, 3 days ago
Si tengo A y a cámbielo por xx Si tengo B y b cámbielo por xx Si tengo C y c cámbielo por xx Salida xxxxxx
upvoted 1 times
...
...
sugisho
Highly Voted 3 years, 5 months ago
[root@centos7 ~]# echo "ABCabc" | sed "s/[ABC] [abc]/xx/" ABCabc [root@centos7 ~]# echo "ABCabc" | sed "s/[ABC][abc]/xx/" ABxxbc
upvoted 22 times
...
LSgeek
Most Recent 2 months, 3 weeks ago
tied on ubuntu output is ABCabc
upvoted 1 times
...
mrfstop
3 months ago
Selected Answer: D
There is a space between the brackets. Copied s/[ABC] [abc]/xx/ from the question into echo "ABCabc" | sed "" and outputs ABCabc.
upvoted 1 times
...
Raafiik
3 months, 3 weeks ago
Selected Answer: D
The regular expression s/[ABC] [abc]/xx/ attempts to match a single character from the set [ABC] (i.e., A, B, or C), followed by a space, and then another single character from the set [abc] (i.e., a, b, or c). In the given string ABCabc, there is no occurrence where a space follows a character from the set [ABC]. Therefore, the regular expression doesn’t find any matches within the string, resulting in no changes to the original string. Hence, the output remains the same as the input string: ABCabc.
upvoted 1 times
...
LNX_RM_Admin
11 months, 1 week ago
Selected Answer: A
i've tried on terminal: right answer is A) ABxxbc
upvoted 1 times
...
ccpmad
1 year, 1 month ago
It's possible that you interpreted the regular expression as if it was being executed with single or double quotes, which could explain the discrepancy in the answer. In a context where the regular expression is executed with single or double quotes, the answer "A. ABxxbc" could be correct, as the regular expression "s/[ABC] [abc]/xx/" would look for an uppercase letter from "A" to "C", followed by a space, followed by a lowercase letter from "a" to "c", and replace it with "xx". However, in a context where single or double quotes are not required to execute the regular expression, the correct answer remains option "B. xxCxxc", as mentioned earlier. It's important to note that the execution of a regular expression can depend on the context and the parameters used, and there may be multiple correct answers.
upvoted 1 times
...
ccpmad
1 year, 1 month ago
in the question statement, it is not specified in what context the regular expression is being used, so it is assumed that it is used in a context where single or double quotes are not required. Therefore, the correct answer remains option "B. xxCxxc", as it is the result of applying the regular expression "s/[ABC] [abc]/xx/" to the string "ABCabc -"
upvoted 1 times
...
DjBouz
1 year, 1 month ago
The correct answer is A
upvoted 2 times
...
totalchod
1 year, 1 month ago
Selected Answer: A
the answer is a
upvoted 2 times
...
Adam_H
1 year, 3 months ago
Selected Answer: D
Running the command echo "ABCabc" | sed "s/[ABC] [abc]/xx/" in Ubuntu 20.04 returns the result "ABCabc", so the correct answer is D.
upvoted 1 times
Adam_H
1 year, 3 months ago
I just realized that the question does not have quotes around s/[ABC] [abc]/xx/ so it returns error "sed: -e expression #1, char 7: unterminated `s' command", which means the question currently has an error. Running the command without quotes or a space returns "ABxxbc", so I don't know which one is correct.
upvoted 1 times
...
Adam_H
1 year, 3 months ago
I just passed the test today, and they do NOT have a space between [ABC][abc], so the correct answer is ABxxbc.
upvoted 4 times
...
...
Iamrandom
1 year, 4 months ago
[root@centos7 ~]# echo "ABCabc" | sed s/[ABC][abc]/xx/ <--- no space, no quotes ABxxbc [root@centos7 ~]# echo "ABCabc" | sed s/[ABC] [abc]/xx/ <--- with space, no quotes sed: -e expression #1, char 7: unterminated `s' command [root@centos7 ~]# echo "ABCabc" | sed "s/[ABC] [abc]/xx/" <--- with space, with quotes ABCabc So either A or D depending if there's a typo or not.
upvoted 3 times
...
TT924
1 year, 4 months ago
Selected Answer: A
A for sure
upvoted 2 times
...
meer01
1 year, 5 months ago
Selected Answer: A
Used with sed, retuns A
upvoted 2 times
...
Wellison
1 year, 8 months ago
Selected Answer: D
[root@centos7 ~]# echo "ABCabc" | sed "s/[ABC] [abc]/xx/" resultado com espaço "s/[ABC] [abc]/xx/" D = ABCabc
upvoted 2 times
Wellison
1 year, 8 months ago
[root@centos7 ~]# echo "ABCabc" | sed "s/[ABC][abc]/xx/" resultado sem espaço "s/[ABC][abc]/xx/" A = ABxxbc
upvoted 1 times
...
...
Lazylinux
1 year, 12 months ago
Selected Answer: A
Definitely A, Tested and as per below comment on how to test it
upvoted 1 times
...
gonzaloco
2 years ago
Selected Answer: A
A is correct
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...