BaşlayınÜcretsiz Başlayın

Lazy approach

You have done some cleaning in your dataset but you are worried that there are sentences encased in parentheses that may cloud your analysis.

Again, a greedy or a lazy quantifier may lead to different results.

For example, if you want to extract a word starting with a and ending with e in the string I like apple pie, you may think that applying the greedy regex a.+e will return apple. However, your match will be apple pie. A way to overcome this is to make it lazy by using ? which will return apple.

The re module and the variable sentiment_analysis are already loaded in your session.

Bu egzersiz

Regular Expressions in Python

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Write a greedy regex expression to match 
sentences_found_greedy = re.____(r"____", ____)

# Print out the result
print(sentences_found_greedy)
Kodu Düzenle ve Çalıştır