How to find a pattern from a text file?

958    Asked by FujiwaraBan in Data Science , Asked on Jan 5, 2020
Answered by Fujiwara Ban

Patterns are words or numbers found from a file when required using regex library from python. Below is the snippet which will help us find that.

Here, the word ‘phone’ appears twice in the text and span() gives the location of the index where the word appears. To find all the matches we use findall () method to find out the total number of matches.




Your Answer

Interviews

Parent Categories