File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 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+ Emails: john.doe@example.com, jane_smith@gmail.com
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 ("\n Email addresses found:" )
24+ print (emails )
25+
26+ if __name__ == "__main__" :
27+ main ()
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments