- Which module in Python is used for regular expressions?
View Answer
Correct answer: B — re
- What will be printed?
1 python 2 import re 3 print(re.match("Edu","Eduinq").group()) View Answer
Correct answer: A — Edu
- Which of the following matches any single character?
View Answer
Correct answer: A — .
- What is the output of print(re.search("inq","Eduinq").group())?
View Answer
Correct answer: A — inq
- Which of the following matches zero or more occurrences?
View Answer
Correct answer: A — *
- What will be printed?
1 python 2 import re 3 print(re.findall("n","Eduinq")) View Answer
Correct answer: A — ['n']
- Which of the following matches one or more occurrences?
View Answer
Correct answer: A — +
- What is the output of print(re.findall("i.","Eduinq"))?
View Answer
Correct answer: A — ['in']
- Which of the following matches zero or one occurrence?
View Answer
Correct answer: A — ?
- What will be printed?
1 python 2 import re 3 print(re.match("E.?u","Eduinq").group()) View Answer
Correct answer: A — Edu
- Which of the following matches beginning of string?
View Answer
Correct answer: A — ^
- What is the output of print(re.match("^E","Eduinq").group())?
View Answer
Correct answer: A — E
- Which of the following matches end of string?
View Answer
Correct answer: A — $
- What will be printed?
1 python 2 import re 3 print(re.search("q$","Eduinq").group()) View Answer
Correct answer: A — q
- Which of the following matches any digit?
View Answer
Correct answer: A — \d
- What is the output of print(re.findall("\d","Eduinq123"))?
View Answer
Correct answer: A — ['1','2','3']
- Which of the following matches non digit?
View Answer
Correct answer: A — \D
- What will be printed?
1 python 2 import re 3 print(re.findall("\D","Eduinq123")) View Answer
Correct answer: A — ['E','d','u','i','n','q']
- Which of the following matches any word character?
View Answer
Correct answer: A — \w
- What is the output of print(re.findall("\w","Eduinq!"))?
View Answer
Correct answer: A — ['E','d','u','i','n','q']
- Which of the following matches non word characters?
View Answer
Correct answer: A — \W
- What will be printed?
1 python 2 import re 3 print(re.findall("\W","Eduinq!")) View Answer
Correct answer: A — ['!']
- Which of the following matches whitespace?
View Answer
Correct answer: A — \s
- What is the output of print(re.findall("\s","Eduinq Python"))?
View Answer
Correct answer: A — [' ']
- Which of the following matches non whitespace?
View Answer
Correct answer: A — \S
- What will be printed?
1 python 2 import re 3 print(re.findall("\S","Eduinq Python")) View Answer
Correct answer: A — ['E','d','u','i','n','q','P','y','t','h','o','n']
- Which of the following matches word boundary?
View Answer
Correct answer: A — \b
- What is the output of print(re.search(r"\bEdu","Eduinq Python").group())?
View Answer
Correct answer: A — Edu
- Which of the following matches non word boundary?
View Answer
Correct answer: A — \B
- What will be printed?
1 python 2 import re 3 print(re.search(r"\Binq","Eduinq").group()) View Answer
Correct answer: A — inq
- Which of the following is used for grouping in regex?
View Answer
Correct answer: A — ()
- What is the output of print(re.search("(Edu)(inq)","Eduinq").groups())?
View Answer
Correct answer: A — ('Edu','inq')
- Which of the following is used for alternation in regex?
View Answer
Correct answer: A — |
- What will be printed?
1 python 2 import re 3 print(re.search("Edu|Python","Eduinq").group()) View Answer
Correct answer: A — Edu
- Which of the following is used for character classes?
View Answer
Correct answer: A — []
- What is the output of print(re.findall("[aeiou]","Eduinq"))?
View Answer
Correct answer: A — ['E','u','i']
- Which of the following is used for negated character classes?
View Answer
Correct answer: A — [^ ]
- What will be printed?
1 python 2 import re 3 print(re.findall("[^aeiou]","Eduinq")) View Answer
Correct answer: A — ['d','n','q']
- Which of the following is used for quantifiers?
View Answer
Correct answer: A — {m,n}
- What is the output of print(re.findall("E.{2}","Eduinq"))?
View Answer
Correct answer: A — ['Edu']
- Which of the following is used for raw strings in regex?
View Answer
Correct answer: A — r""
- What will be printed?
1 python 2 import re 3 print(re.search(r"\d+","Eduinq123").group()) View Answer
Correct answer: A — 123
- Which of the following is used for compiling regex?
View Answer
Correct answer: A — re.compile()
- What is the output of below code?
1 python 2 import re 3 pattern = re.compile("Edu") 4 print(pattern.match("Eduinq").group()) View Answer
Correct answer: A — Edu
- Which of the following is used to substitute in regex?
View Answer
Correct answer: A — re.sub()
- What will be printed?
1 python 2 import re 3 print(re.sub("Edu","Python","Eduinq")) View Answer
Correct answer: A — Pythoninq
- Which of the following is used to split string by regex?
View Answer
Correct answer: A — re.split()
- What is the output of print(re.split("\s","Eduinq Python"))?
View Answer
Correct answer: A — ['Eduinq','Python']
- Which of the following is used to escape special characters?
View Answer
Correct answer: A — \
- What will be printed?
1 python 2 import re 3 print(re.search("\.","Eduinq.com").group()) View Answer
Correct answer: A — .