Skip to content

Commit 9fca401

Browse files
Filter_Text added
1 parent dd74c39 commit 9fca401

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

Filter_Text/Filter_Text.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import re
2+
3+
def filter_text(text, pattern):
4+
filtered_text = re.findall(pattern, text)
5+
return filtered_text
6+
7+
def main():
8+
sample_text = """
9+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
10+
Phone numbers: +1 (123) 456-7890, 555-1234, 9876543210
11+
12+
"""
13+
14+
# Filter phone numbers
15+
phone_pattern = r'\+?1? ?\(\d{3}\) ?\d{3}-\d{4}|\d{10}'
16+
phone_numbers = filter_text(sample_text, phone_pattern)
17+
print("Phone numbers found:")
18+
print(phone_numbers)
19+
20+
# Filter emails
21+
email_pattern = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
22+
emails = filter_text(sample_text, email_pattern)
23+
print("\nEmail addresses found:")
24+
print(emails)
25+
26+
if __name__ == "__main__":
27+
main()

Filter_Text/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Filter_Text
2+
3+
Short description of package/script
4+
5+
- This Script Was simple to setup
6+
- Need import re
7+
8+
## Setup instructions
9+
10+
Just Need to Import re then run the Filter_Text.py file and for running python3 is must be installed!
11+
12+
## Detailed explanation of script, if needed
13+
14+
This Script Is Only for Filter text use only!
15+
16+
## Author(s)
17+
18+
Kalivarapubindusree

0 commit comments

Comments
 (0)