Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Advanced Search Function 2/2 | Regex Wizards (Project)
Regex Wizards (Project)

book
Advanced Search Function 2/2

Compito

Swipe to start coding

  1. Import re.
  2. Define a text variable as "The cost is $5.".
  3. Search for any numerical value in the string.
  4. Print the output.

Soluzione

import re

# Search for a digit in the text "The cost is $5."
text = "The cost is $5."
x = re.search("\d", text)
print(x) # Output: <re.Match object; span=(13, 14), match='5'>

Mark tasks as Completed
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 4
AVAILABLE TO ULTIMATE ONLY
some-alt