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

Kursusindhold

Regex Wizards (Project)

book
Advanced Search Function 1/2

The Search function also provides some advanced matching combinations. We will now introduce the most famous one and later practice them in the exercise:

  • \A - Matches if the specified characters are at the start of a string;
  • \b - Matches if the specified characters are at the beginning or end of a word;
  • \D - Matches any non-decimal digit. Equivalent to [^0-9];
  • \d - Matches any decimal digit. Equivalent to [0-9];
  • \B - Opposite of \b. Matches if the specified characters are not at the beginning or end of a word;
  • . - period matches any single character.
Opgave

Swipe to start coding

  1. Import re.
  2. Define a text variable as "The cat in the hat".
  3. Search for any 3 characters finishing with "at".
  4. Print the output.

Løsning

Mark tasks as Completed
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

course content

Kursusindhold

Regex Wizards (Project)

book
Advanced Search Function 1/2

The Search function also provides some advanced matching combinations. We will now introduce the most famous one and later practice them in the exercise:

  • \A - Matches if the specified characters are at the start of a string;
  • \b - Matches if the specified characters are at the beginning or end of a word;
  • \D - Matches any non-decimal digit. Equivalent to [^0-9];
  • \d - Matches any decimal digit. Equivalent to [0-9];
  • \B - Opposite of \b. Matches if the specified characters are not at the beginning or end of a word;
  • . - period matches any single character.
Opgave

Swipe to start coding

  1. Import re.
  2. Define a text variable as "The cat in the hat".
  3. Search for any 3 characters finishing with "at".
  4. Print the output.

Løsning

Mark tasks as Completed
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
Vi beklager, at noget gik galt. Hvad skete der?
some-alt