- Which of the following enables non capturing groups?
View Answer
Correct answer: A — (?: )
- What will be printed?
1 python 2 import re 3 print(re.search("(?:Edu)inq","Eduinq").group()) View Answer
Correct answer: A — Eduinq
- Which of the following enables named groups?
View Answer
Correct answer: A — (?P<name>pattern)
- What is the output of below code?
1 python 2 import re 3 m = re.search("(?P<grp>Edu)inq","Eduinq") 4 print(m.group("grp")) View Answer
Correct answer: A — Edu
- Which of the following enables lookahead assertion?
View Answer
Correct answer: A — (?=pattern)
- What will be printed?
1 python 2 import re 3 print(re.search("Edu(?=inq)","Eduinq").group()) View Answer
Correct answer: A — Edu
- Which of the following enables negative lookahead?
View Answer
Correct answer: A — (?!pattern)
- What is the output of print(re.search("Edu(?!abc)","Eduinq").group())?
View Answer
Correct answer: A — Edu
- Which of the following enables lookbehind assertion?
View Answer
Correct answer: A — (?<=pattern)
- What will be printed?
1 python 2 import re 3 print(re.search("(?<=Edu)inq","Eduinq").group()) View Answer
Correct answer: A — inq
- Which of the following enables negative lookbehind?
View Answer
Correct answer: A — (?<!pattern)
- What is the output of print(re.search("(?<!Python)Edu","Eduinq").group())?
View Answer
Correct answer: A — Edu
- Which of the following enables conditional regex?
View Answer
Correct answer: A — (?(id)yes|no)
- What will be printed?
1 python 2 import re 3 print(re.search("(?(1)Edu|inq)","inq")) View Answer
Correct answer: A — inq
- Which of the following enables atomic grouping?
View Answer
Correct answer: A — (?>pattern)
- What is the output of print(re.search("(?>Edu)inq","Eduinq").group())?
View Answer
Correct answer: A — Eduinq
- Which of the following enables inline flags?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 python 2 import re 3 print(re.search("(?i)edu","EDUinq").group()) View Answer
Correct answer: A — EDU
- Which of the following enables verbose regex?
View Answer
Correct answer: C — Both A and B
- What is the output of below code?
1 python 2 import re 3 pattern = re.compile(r""" 4 Edu # match Edu 5 inq # match inq 6 """,re.VERBOSE) 7 print(pattern.match("Eduinq").group()) View Answer
Correct answer: A — Eduinq
- Which of the following enables inline comments in regex?
View Answer
Correct answer: A — re.VERBOSE
- What will be printed?
1 python 2 import re 3 pattern = re.compile(r"Edu #comment",re.VERBOSE) 4 print(pattern.match("Edu").group()) View Answer
Correct answer: A — Edu
- Which of the following enables backreference by number?
View Answer
Correct answer: D — All of the above
- What is the output of below code?
1 python 2 import re 3 m = re.search(r"(Edu)\1","EduEdu") 4 print(m.group()) View Answer
Correct answer: A — EduEdu
- Which of the following enables backreference by name?
View Answer
Correct answer: A — (?P=name)
- What will be printed?
1 python 2 import re 3 m = re.search(r"(?P<grp>Edu)(?P=grp)","EduEdu") 4 print(m.group()) View Answer
Correct answer: A — EduEdu
- Which of the following enables possessive quantifiers (not backtracking)?
View Answer
Correct answer: D — All of the above
- What is the output of print(re.search("Edu*+","Eduuuuu").group())?
View Answer
Correct answer: A — Eduuuuu
- Which of the following enables inline flag for multiline?
View Answer
Correct answer: A — (?m)
- What will be printed?
1 python 2 import re 3 print(re.search("(?m)^inq","Edu\ninq").group()) View Answer
Correct answer: A — inq
- Which of the following enables inline flag for dotall?
View Answer
Correct answer: A — (?s)
- What is the output of print(re.search("(?s).+","Edu\ninq").group())?
View Answer
Correct answer: A — Edu\ninq
- Which of the following enables inline flag for case insensitive?
View Answer
Correct answer: A — (?i)
- What will be printed?
1 python 2 import re 3 print(re.search("(?i)edu","EDUinq").group()) View Answer
Correct answer: A — EDU
- Which of the following enables inline flag for locale dependent?
View Answer
Correct answer: A — (?L)
- What is the output of print(re.search("(?L)\w+","Eduinq").group())?
View Answer
Correct answer: A — Eduinq
- Which of the following enables inline flag for unicode matching?
View Answer
Correct answer: A — (?u)
- What will be printed?
1 python 2 import re 3 print(re.search("(?u)\w+","Eduinq").group()) View Answer
Correct answer: A — Eduinq
- Which of the following enables inline flag for default greedy quantifiers?
View Answer
Correct answer: A — (?U)
- What is the output of print(re.search("(?U).+?","Eduinq").group())?
View Answer
Correct answer: A — E
- Which of the following enables atomic grouping in regex?
View Answer
Correct answer: A — (?>pattern)
- What will be printed?
1 python 2 import re 3 print(re.search("(?>Edu)inq","Eduinq").group()) View Answer
Correct answer: A — Eduinq
- Which of the following enables conditional matching with named group?
View Answer
Correct answer: A — (?(grp)yes|no)
- What is the output of below code?
1 python 2 import re 3 m = re.search(r"(?P<grp>Edu)?(?(grp)inq|Python)","Eduinq") 4 print(m.group()) View Answer
Correct answer: A — Eduinq
- Which of the following enables recursive regex?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 python 2 import re 3 pattern = re.compile(r"(Edu)(?R)?") 4 print(pattern.match("EduEdu").group()) View Answer
Correct answer: A — EduEdu
- Which of the following enables balancing groups in regex?
View Answer
Correct answer: A — (?<name1-name2>pattern)
- What is the output of print(re.search("(?<open-close>Edu)","Edu").group())?
View Answer
Correct answer: A — Edu
- Which of the following enables inline flag for ignore pattern whitespace?
View Answer
Correct answer: A — (?x)
- What will be printed?
1 python 2 import re 3 pattern = re.compile(r"Edu inq",re.X) 4 print(pattern.match("Eduinq").group()) View Answer
Correct answer: A — Eduinq