nerdexam
Huawei

H13-311_V3.5 · Question #130

Which of the following description about Python regular expression is not correct?

The correct answer is D. re regular expressions can only process string data not numeric data. Option D is marked correct because it's the false statement - Python's re module can absolutely process numeric data; it operates on strings, but those strings can contain digits, and patterns like \d+ match numeric characters within strings, making D's claim of "only string…

Huawei AI Development Platforms and Solutions

Question

Which of the following description about Python regular expression is not correct?

Options

  • APython has added there regular expression module since version 1.5.
  • Bre regular expression module gives the Python language all the regular expression functionality.
  • Cre regular expressions are powerful tools for working with strings.
  • Dre regular expressions can only process string data not numeric data

How the community answered

(18 responses)
  • B
    6% (1)
  • C
    11% (2)
  • D
    83% (15)

Explanation

Option D is marked correct because it's the false statement - Python's re module can absolutely process numeric data; it operates on strings, but those strings can contain digits, and patterns like \d+ match numeric characters within strings, making D's claim of "only string data, not numeric data" misleading and incorrect. Option A is true: the re module was introduced in Python 1.5 as a replacement for the older regex and regsub modules. Option B is true: re brings full regular expression functionality to Python, including pattern matching, searching, splitting, and substitution. Option C is true: regular expressions are widely recognized as powerful string-processing tools for tasks like validation, parsing, and transformation.

Memory tip: Think of it this way - regular expressions work on text, and text can represent anything, including numbers. The restriction is on the type (str vs int), not the content - you just need to feed the re module a string, and it doesn't care what characters are inside it.

Topics

#Python regex#re module#string processing#pattern matching

Community Discussion

No community discussion yet for this question.

Full H13-311_V3.5 Practice