A brief look at time......
Tuesday, August 17, 2021
Email Slicer in Python
We will slice the email address and get the username and domain using three different methods:
1) The conventional method of slicing
2) Using split function
3) Regex(Regular Library) Library
So, let's start looking at each method in detail with the code.
1) Slicing
First of all we will ask for the email-address. Then we will write two expressions to slice the email address each for username and domain.
Finally we will print the username and domain.
2) Using Split function
Here we will input the email-address. Then we will split the email address from '@' using just one statement. i.e. email.split('@'). It will split the string from '@' and return list. Then we will print the list
3)Using Regex
Here, we will first import the re module. Then we will ask for the user input (Email address to be sliced).
Then we will write a regular expression which will split our string from '@'. We can also split from more than one element by just adding more elements with a space with @. The print(result) will print a sliced list because the regex expression will return a list which is been splitted by '@'
For example if I want my email address to split from '.' and '#' too, then I will write the expression as follows,
Then we will print the list which was splitted, here specifically we will print using the f string. Although we can use any method to print. Below is the complete code for the Email Slicer using regex library
Time
A brief look at time......
Popular Posts
-
Procrastination might be the word that would have brought you here. We all exhibit procrastination but for different reasons. When we go to ...
-
Hii everyone! Setting up sublime text for competitive coding is easy but not at the very first try. Today, your that first try will be...
-
After reading this question you might think about measuring sun’s temperature probably by sending some sort space probe with thermometer...
-
The Copying Machine Chester Carlson was the inventor of photocopying. Copying machines works on the electrostatic process called Xer...
-
Listening the word 'Quantum Computers' these days makes us think of a substantial significance that it has or will have in the...
-
Let us take one example, if you drop a pebble in still water, the water surface gets disturbed. This disturbance is not confined to on...
-
Binary search is basically a searching algorithm used to search for a particular element in any given array. There are in fact many ...
-
It was all going well until the pointers came in! Has this statement ever crossed your mind? But you should know that the pointer is an i...
-
We will slice the email address and get the username and domain using three different methods: 1) The conventional method of slicing ...
-
The new node will be added at the end of the linked list. Example: Input Linked List : 1➞ 2➞ 3➞ 4➞ NULL 5 Output Linked list : 1➞ 2➞ 3➞ ...