Question

In: Computer Science

I had a question like this but I forgot to add more and I could not...

I had a question like this but I forgot to add more and I could not edit it. So here is the new one with more explanation.

I am confused with my Python assignment. I have to write a specification for an email address, Then change the test strings in the code to one string with a valid email address and the other without a valid email address.

This my example/code that it is supposed to be used as a guide:

import re

def text_match(text):

patterns = '^\w+'

if re.search(patterns, text):

return 'Found a match!'

else:

return('Not matched!')

print(text_match("My teacher’s email is [email protected]"))

print(text_match("My teacher has no email address"))

For some reason chegg does not want to indent my lines. the if and else statement should be properly indented in the example

Solutions

Expert Solution

RAW CODE

import re

def text_match(text):
    ### alphabet or digit + @ + alphabet or digit + . + alphabet or digit or . 
    patterns = '([a-zA-Z0-9_.]+@[a-zA-Z0-9]+\.[a-zA-Z0-9.]+)'
    if re.search(patterns, text):
        return 'Found a match!'
    else:
        return('Not matched!')

print(text_match("My teacher’s email is [email protected]"))

print(text_match("My teacher has no email address"))

SCREENSHOTS (CODE AND OUTPUT)

##### FOR ANY QUERY, KINDLY GET BACK, THANKYOU. #####


Related Solutions

I have a BigInt class I created that works correctly. I would like to add a...
I have a BigInt class I created that works correctly. I would like to add a constructor BigInt(string s, int base) that creates a BigInt operating in the given base. The newly extended class should work with any base between 2 and 36, using the digits 0, 1, …, 9, A, B, C, …, Z. How do I do this from what I have? (you may add new data members and such of course) #include <string> #include <vector> class BigInt...
Think about and reflect upon particular ways that religion could add to one or more of...
Think about and reflect upon particular ways that religion could add to one or more of the anxiety disorders we have identified.
A person who was slightly dehydrated went to donate blood, but they forgot that they had...
A person who was slightly dehydrated went to donate blood, but they forgot that they had to go home to feed their mini dinosaur (if you don't feed them regularly, they get really mean), so instead of waiting in the recovery chair, this silly person stood up quickly and walked out the door. As they stood up, they felt dizzy and light headed and almost passed out. a. This person suffered from a quick decrease in MAP, draw the negative...
Hi, I need the HTML5 code for the below. About Me **Would like to add a...
Hi, I need the HTML5 code for the below. About Me **Would like to add a image of a plane or something related to travel here. Mia Jo I am taking this class to earn my Computer programmer CL1. Things I Like to Do: Spend time with family Traveling People Watch Places I Want to Go or Have Visited: Dubai- December'18 Enjoyed shopping and the desert safari the most. Cuba- August '18 Enjoyed learning about the culture and history. China-...
Greta had a cold over the weekend and forgot to study for the DMV knowledge test....
Greta had a cold over the weekend and forgot to study for the DMV knowledge test. All questions were multiple choice with 5 options. You need to get 80% of the questions correct in order to pass the test. If there were 35 questions on the DMV test that Greta randomly guessed, what is the probability that: a) I got at most 15 of the 35 questions correct? b) I guessed 80% or more of the questions correctly.(hint: how many...
Hello! Html question. I am trying to add a background to a page. How would i...
Hello! Html question. I am trying to add a background to a page. How would i do this? I have tried using a jpg. The code is posted below. i used the background-image: url function. Any help of different ways to do this would be appreciated! Thank you! CODE: <!DOCTYPE html> <html> <head> <style> ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a { display: block; color: white; text-align:...
I was wondering if I could get a step by step process to answer this question?
I was wondering if I could get a step by step process to answer this question?
Owen Company forgot to accrue $3,000 of salaries its employees had earned at the end of...
Owen Company forgot to accrue $3,000 of salaries its employees had earned at the end of 2019. It paid and expensed the salaries in 2020. It also, in 2019, recorded $4,000 of sales as an account receivable; however, the sale really did not take place until 2020, and it should have recognized the revenue in 2020. It collected the money from the sale early in 2020. Provide the impact of the errors on the following: Assets as of 12/31/19: $_____________...
Monopolistic competition is more like _____ in the short run and more like _____ in the...
Monopolistic competition is more like _____ in the short run and more like _____ in the long run in terms of how much economic profit is earned. monopoly, oligopoly monopoly, perfect competition oligopoly, monopoly oligopoly, perfect competition perfect competition, monopoly perfect competition, oligopoly
Can you add more comments explaining what this code does? i commented what I know so...
Can you add more comments explaining what this code does? i commented what I know so far #include<stdio.h> #include<pthread.h> #include<semaphore.h> #include<unistd.h> sem_t mutex,writeblock; int data = 0,rcount = 0; int sleepLength = 2; // used to represent work void *reader(void *arg) { int f; f = ((int)arg); sem_wait(&mutex); // decrement by 1 if rcount = rcount + 1; if(rcount==1) sem_wait(&writeblock); sem_post(&mutex); printf("Data read by the reader%d is %d\n",f,data); //shows current reader and data sleep(sleepLength); // 1 second of "work" is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT