---
title: "Discussion on \"Using Python Regex to extract phone numbers from a text file\" | Hashnode"
description: "Discussion on \"Using Python Regex to extract phone numbers from a text file\". with open ('lorem.txt', 'rt') as myfile:  # Open lorem.txt for reading text\n    contents = myfile.read()              # Read the entire file to a string\n# print(contents)                         # Print the string if you want to\n\n# Now let's extract ..."
url: "https://hashnode.com/posts/using-python-regex-to-extract-phone-numbers-from-a-text-file/647330cc764935a4b900c07e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Using Python Regex to extract phone numbers from a text file](https://sihan.hashnode.dev/using-python-regex-to-extract-phone-numbers-from-a-text-file?utm_source=hashnode&utm_medium=feed)

with open ('lorem.txt', 'rt') as myfile: # Open lorem.txt for reading text contents = myfile.read() # Read the entire file to a string # print(contents) # Print the string if you want to # Now let's extract ...

May 28, 2023 · 2 min read · sihan.hashnode.dev  
Read the article

-   [#regex](https://hashnode.com/tag/regex)
-   [#developer](https://hashnode.com/tag/developer)
-   [#dataengineering](https://hashnode.com/tag/dataengineering)
-   [#dataenthusiast](https://hashnode.com/tag/dataenthusiast)
-   [#linkedin](https://hashnode.com/tag/linkedin)

## Written by

[Data Sensei](https://hashnode.com/@sibbirsihan)

@sibbirsihan · United Kingdom

  
[View profile](https://hashnode.com/@sibbirsihan)

for the data, by the data, of the data

A data analytics engineer with four years of experience working as a data engineer. Holds a MSc in Data.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
