-
-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d87a8d8
commit 964141f
Showing
5 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import re | ||
|
||
|
||
def extract_domain_parts(domain): | ||
# Use a regular expression to extract the domain parts | ||
pattern = r'(?:\w+\.)?(\w+)\.(\w+)' | ||
match = re.match(pattern, domain) | ||
|
||
if match: | ||
subdomain = match.group(1) | ||
top_level_domain = match.group(2) | ||
return subdomain, top_level_domain | ||
else: | ||
return None, None | ||
|
||
|
||
# Example usage | ||
domain = "sub.example.ae" | ||
subdomain, top_level_domain = extract_domain_parts(domain) | ||
print("Subdomain:", subdomain) | ||
print("Top-Level Domain:", top_level_domain) |