match vs search vs fullmatch

Easy ⏱ 8 min 82% acceptance ★★★★★ 4.6
Write where_digit(text) returning a tuple of three booleans: does r'\d+' produce a hit with re.match (start-anchored), re.search (anywhere), and re.fullmatch (entire string)? For 'ab12' that is (False, True, False) — the distinction interviews love.

Examples

Example 1
Input
where_digit('ab12')
Output
(False, True, False)
Explanation

Digits exist but neither start nor span the whole string.

Constraints

  • Use all three functions.
  • Convert results to bool.

Topics

Regular Expressionsmatch/search semantics

Companies

TCSCognizantHCLTech

Hints

Hint 1

match only anchors at position 0.

Hint 2

bool(m) converts a Match/None cleanly.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.