1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which module in Python is used for regular expression operations?
Which character is used to represent any single character in a regular expression pattern?
What does the "^" character represent in a regular expression pattern?
What will be the output of the following code?
import re
pattern = r"co[a-z]+e"
text = "I love coding and coffee!"
result = re.findall(pattern, text)
print(result)
What will be the output of the following code?
import re
pattern = r"\b\d{3}-\d{3}-\d{4}\b"
text = "Contact me at 123-456-7890"
result = re.search(pattern, text)
print(result.group())
What will be the output of the following code?
import re
pattern = r"\b[A-Z][a-z]+\b"
text = "The quick Brown fox jumps over the lazy Dog"
result = re.findall(pattern, text)
print(result)
What will be the output of the following code?
import re
pattern = r"\b([a-z]+) \1\b"
text = "The cat in the hat is the best cat"
result = re.findall(pattern, text)
print(result)
What will be the output of the following code?
import re
pattern = r"\d+"
text = "There are 10 apples and 20 oranges."
result = re.split(pattern, text)
print(result)
Given the following code, what will be the output?
import re
pattern = r"\b[A-Za-z]+\b"
text = "The quick brown fox jumps over the lazy dog."
result = re.findall(pattern, text)
print(len(result))
Which regular expression pattern can be used to match a URL starting with "https://"?
What will be the output of the following code?
import re
pattern = r"\d{2}-\d{2}-\d{4}"
text = "DOB: 01-01-2000, SSN: 123-45-6789"
result = re.findall(pattern, text)
print(result)
What will be the output of the following code?
import re
pattern = r"\b[A-Z][a-z]+\b"
text = "The quick brown fox jumps over the lazy dog."
result = re.sub(pattern, "animal", text)
print(result)