Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Group function 2/2 | Regex Tutorial
Regex Wizards (Project)

book
Group function 2/2

Завдання

Swipe to start coding

  1. Import re.
  2. Define a text variable as "123-456-7890".
  3. Search for the first vowel value in the string using the following grammar: ^\d{3}-\d{3}-\d{4}$.
  4. Print the output using the group() function.

Рішення

import re

# Matching a phone number
phone_number = "123-456-7890"
phone_regex = r'^\d{3}-\d{3}-\d{4}$'
x = re.search(phone_regex, phone_number)
print(x.group()) # Output: 123-456-7890

Mark tasks as Completed
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 6

Запитати АІ

expand
ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt