Question

In: Computer Science

Using Python answer the following questions. 1. Describe the class of strings matched by the following...

Using Python answer the following questions.

1. Describe the class of strings matched by the following regular expressions. Provide examples
that can be captured by the regular expression pattern.
(a) [A-Za-z]+
(b) ^[A-Za-z]+.\d$
2. Which of the following matches regexp /(very )+(thick )?use(ful|less) book/?
Explain why.
A. very thick book
B. very very useful book
C. thick useless book
D. very useless book

Solutions

Expert Solution

1. Describe the class of strings matched by the following regular expressions. Provide examples
that can be captured by the regular expression pattern.
(a) [A-Za-z]+
=> Above Regex match An string which is not empty and contains only alphabets


(b) ^[A-Za-z]+.\d$
=> The regex matches a string which starts with any number of alphabets, then one character of any type, And ending on a digit.


2. Which of the following matches regexp /(very )+(thick )?use(ful|less) book/?
Explain why.
A. very thick book => Does not match, because it does not contain "use"

B. very very useful book => Matches.. Very can be repeated any number of times.. thick is optional. Any of ful or less need to be used.


C. thick useless book
=> Does not mathc, Because very should be occurring 0 or more times.

D. very useless book
=> Matches.. Thick is optional, So it matched.

**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

Using Python In this assignment we will try to add tuples, lists, if statements and strings...
Using Python In this assignment we will try to add tuples, lists, if statements and strings to our program. For example, you can ask for a user for a couple items, their name and age – and depending on their age, print out a predefined list. You could ask for some string input and decide to do something with the output. You could ask for three items, 1) age, 2) are you a male or female and 3) are your...
using python 1. #Write a function called multiply_file_by_index. This function #should take two parameters, both strings....
using python 1. #Write a function called multiply_file_by_index. This function #should take two parameters, both strings. The first string is #the filename of a file to which to write (output_file), and #the second string is the filename of a file from which to read #(input_file). # #In the input file, there will be an integer on every line. #To the output file, you should write the integer from the #original file multiplied by the line number on which it #appeared....
Using the sec 10-k answer the following questions: Nike corporation 1- calculate working capital and describe...
Using the sec 10-k answer the following questions: Nike corporation 1- calculate working capital and describe how it changed from last year. 2- If the company has treasury stock, is it increasing or decreasing in value? remember that the normal balance for treasury stock is negative value (debit balance) 3- what are the value for other comprehensive net income(or net loss) and retained earnings (or accumulated deficit) how are these values changing?
Please answer the following questions, for a business class 1) Discuss at least 2 advantages and...
Please answer the following questions, for a business class 1) Discuss at least 2 advantages and 2 disadvantages of being an entrepreneur 2) The elements of the business environment are: economic and legal, technological completive, social and global. Select any two and discuss the potential impact on a business. 3) Explain the relationship between supply and demand in a free market economy? How does the equilibrium point related to the concept of supply and demand? 4.) Compare and contrast Standard...
Using the following powerpoint answer the following questions on the study guide. THESE ARE THE QUESTIONS:...
Using the following powerpoint answer the following questions on the study guide. THESE ARE THE QUESTIONS: 1.)Be able to explain why ER signal sequences are thought to be necessary and sufficient 2.)Know how the cell regulates the activity of transporters, receptors, and enzymatic proteins. 3.)Be able to explain, in moderate detail, the three main mechanisms of protein transport into organelles. 4.)Be able to describe the transport of soluble, single-pass and double-pass transmembrane proteins across the ER membrane. 5.)Know what happens...
  Answer the questions related to the following code:             Class B             {      &nbs
  Answer the questions related to the following code:             Class B             {                         Public:                                     Void b1();                         Protected:                                     Void b2();             };             Class A : public B             {                         Public:                                     Void  a1();                         Protected: Void  a2();             };             Class C: public A               {                         Public:                                     Void c1();             }; Void main () { B temp1; A temp2; C temp3; }    Name all member functions of all classes visible through temp1 in the main function? Name all member functions of all classes visible through temp2 in the main function? Name all...
(waves class) please answer the questions in the following order: 1. if you were shown three...
(waves class) please answer the questions in the following order: 1. if you were shown three different interference patterns (double slit, single slit, and diffraction grating), how could you tell the difference between them? 2. Newton thought that light wasnt a wave because he couldn’t see diffraction or interference. Imagine you are transported back in time to convince him otherwise. Write a 1-2 paragraph explanation for Newton explaining why he does not see these features despite the wave of natural...
A. Answer Following questions. 1.A large number of class II promoters in the human genome lack...
A. Answer Following questions. 1.A large number of class II promoters in the human genome lack TATA boxes. How does RNA Pol II recruitment differ between promoters with a TATA box and TATA-less promoters (2 pts)? List 2 protein complexes that interact with the CTD of RNA Pol II during transcription 2. What class II gene(s) do not have a polyA tail (1pt)? 3.Polymerase recycling is an important mechanism for achieving high expression levels of a particular gene. What factors...
1. The government decreases taxes. (a) Answer the following questions using the IS-LM model: In the...
1. The government decreases taxes. (a) Answer the following questions using the IS-LM model: In the short-run, how does the policy affect the level of national income (Y ) and the real interest rate (r)? Include the appropriate diagram. How does the policy affect the levels of (i) consumption (C), (ii) investment (I), and (iii) government expenditure (G)? How do you know? (b) Use the long-run model of loanable funds to answer the following questions: In the long-run, how does...
Answer the following questions related to the topic of fluids and electrolytes: 1. Describe each of...
Answer the following questions related to the topic of fluids and electrolytes: 1. Describe each of the following disorders including its signs and symptoms and treatment: • Hypo / Hypernatremia • Hypo / Hyperkalemia • Hypo / Hypercalcemia • Hypo / Hypermagnesemia • Hypo / Hyperphosphatemia • Hypo / Hyperchloremia
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT