101-500 Exam QuestionsBrowse all questions from this exam

101-500 Exam - Question 96


What is the output when the regular expression s/[ABC] [abc]/xx/ is applied to the following string?

ABCabc -

Show Answer
Correct Answer: CD

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.

Discussion

17 comments
Sign in to comment
cast7omadrid1Option: A
Mar 12, 2020

The correct answer is A -> ABxxbc. You have to try it inside a file, open it with vim and do :s/[ABC] [abc]/xx/

luismonge
Apr 15, 2024

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

sugishoOption: A
Nov 3, 2020

[root@centos7 ~]# echo "ABCabc" | sed "s/[ABC] [abc]/xx/" ABCabc [root@centos7 ~]# echo "ABCabc" | sed "s/[ABC][abc]/xx/" ABxxbc

IamrandomOption: A
Dec 9, 2022

[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.

WellisonOption: D
Aug 25, 2022

[root@centos7 ~]# echo "ABCabc" | sed "s/[ABC] [abc]/xx/" resultado com espaço "s/[ABC] [abc]/xx/" D = ABCabc

Wellison
Aug 25, 2022

[root@centos7 ~]# echo "ABCabc" | sed "s/[ABC][abc]/xx/" resultado sem espaço "s/[ABC][abc]/xx/" A = ABxxbc

meer01Option: A
Nov 1, 2022

Used with sed, retuns A

TT924Option: A
Dec 4, 2022

A for sure

totalchodOption: A
Mar 6, 2023

the answer is a

DjBouzOption: A
Mar 17, 2023

The correct answer is A

RaafiikOption: D
Jan 5, 2024

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.

LazylinuxOption: A
Apr 28, 2022

Definitely A, Tested and as per below comment on how to test it

Adam_HOption: D
Jan 16, 2023

Running the command echo "ABCabc" | sed "s/[ABC] [abc]/xx/" in Ubuntu 20.04 returns the result "ABCabc", so the correct answer is D.

Adam_H
Jan 16, 2023

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.

Adam_H
Jan 17, 2023

I just passed the test today, and they do NOT have a space between [ABC][abc], so the correct answer is ABxxbc.

ccpmadOption: B
Mar 24, 2023

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 -"

ccpmadOption: B
Mar 24, 2023

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.

LNX_RM_AdminOption: A
May 20, 2023

i've tried on terminal: right answer is A) ABxxbc

mrfstopOption: D
Jan 23, 2024

There is a space between the brackets. Copied s/[ABC] [abc]/xx/ from the question into echo "ABCabc" | sed "" and outputs ABCabc.

LSgeekOption: D
Jan 31, 2024

tied on ubuntu output is ABCabc

JoCi32Option: D
Jun 18, 2024

Ubuntu:~$ cat file1 ABCabc Ubuntu:~$ sed "s/[ABC] [abc]/xx/" < file1 ABCabc ---- The answer is D. There is a space between the [ABC] [abc]. If there was no space, then the answer would be A.