You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Explain the difference between the following data types: string, list, tuple and set
428
425
2._I am a teacher and I love to inspire and teach people._ How many unique words have been used in the sentence? Use the split methods and set to get the unique words.
429
426
430
-
431
427
🎉 CONGRATULATIONS ! 🎉
432
428
433
429
[<< Day 6](../06_Day_Tuples/06_tuples.md) | [Day 8 >>](../08_Day_Dictionaries/08_dictionaries.md)
Copy file name to clipboardExpand all lines: 18_Day_Regular_expressions/18_regular_expressions.md
+43-40Lines changed: 43 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,11 +59,11 @@ import re
59
59
60
60
To find a pattern we use different set of *re* character sets that allows to search for a match in a string.
61
61
62
-
**re.match()*: searches only in the beginning of the first line of the string and returns matched objects if found, else returns None.
63
-
**re.search*: Returns a match object if there is one anywhere in the string, including multiline strings.
64
-
**re.findall*: Returns a list containing all matches
65
-
**re.split*:Takes a string, splits it at the match points, returns a list
66
-
**re.sub*: Replaces one or many matches within a string
62
+
-*re.match()*: searches only in the beginning of the first line of the string and returns matched objects if found, else returns None.
63
+
-*re.search*: Returns a match object if there is one anywhere in the string, including multiline strings.
64
+
-*re.findall*: Returns a list containing all matches
65
+
-*re.split*:Takes a string, splits it at the match points, returns a list
66
+
-*re.sub*: Replaces one or many matches within a string
67
67
68
68
#### Match
69
69
@@ -129,7 +129,7 @@ substring = txt[start:end]
129
129
print(substring) # first
130
130
```
131
131
132
-
As you can see, search is much better than match because it can look for the pattern throughout the text. Search returns a match object with a first match that was found, otherwise it returns _None_. A much better *re* function is *findall*. This function checks for the pattern through the whole string and returns all the matches as a list.
132
+
As you can see, search is much better than match because it can look for the pattern throughout the text. Search returns a match object with a first match that was found, otherwise it returns *None*. A much better *re* function is *findall*. This function checks for the pattern through the whole string and returns all the matches as a list.
1. What is the most frequent word in the following paragraph?
394
+
392
395
```py
393
396
paragraph ='I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.
2. The position of some particles on the horizontal x-axis are -12, -4, -3 and -1 in the negative direction, 0 at origin, 4 and 8 in the positive direction. Extract these numbers from this whole text and find the distance between the two furthest particles.
0 commit comments