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

book
Advanced Search Function 2/2

Opgave

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.

Løsning

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
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
AVAILABLE TO ULTIMATE ONLY
some-alt