please Answer the following regular expressions questions(also do number 9)
Q4 Choose the pattern that finds all filenames in
which the first letters of the filename are astA, followed by
a
digit, followed by the file extension .txt.
1) astA[[:digit:]]\.txt
2) astA[[0-9]].txt
3) astA.\.txt
4) astA[[:digit:]].txt
Q5 What's the difference between [0-z]+ and \w+ ?
1) The first one accepts 0 and z and the other doesn't.
2) The first one doesn't allow for uppercase letters.
3) The first one accepts more punctuation characters than the
second one.
4) Nothing. They're identical.
Q6 What does the regular expression (\d{1,2}\/\d{1,2}\/\d{4} most
likely represent?
1) An American ZIP code
2) A date
3) A phone number
4) A price
Q7 What does the regular expression [a-zA-Z0-9_]{3,14} most likely
represent?
1) An e-mail address
2) A street address
3) A username
4) A set of X and Y coordinates
Q8 What does the regular expression
^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\
[AP]M))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$
most likely represent?
1) A street address
2) A name
3) A time
4) A date
Q9 The regular expression ^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z]
\d[A-Z]\d$ is designed to validate American ZIP Codes
and Canadian Postal Codes but there are two problems with it. What
is one of the flaws?
1) It doesn't allow for leaving the space out after the third
character in the Canadian Postal Code.
2) American ZIP codes that start with 0 aren't accepted.
3) It requires that the string contain an American ZIP Code
followed by a Canadian Postal Code.
4) It allows for American ZIP codes with 9 digits.
Q10 What does the regular expression
^([0-3]|[0-9][0-9]|4[0-5][0-9]|46[0-6])$ most likely
represent?
1) A range of numeric values from 0 to 499.
2) A range of numeric values from 399 to 499.
3) A range of numeric values from 399 to 466
4) A range of numeric values from 0 to 466.
Please find my answer in details.
Please find the answer below
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q4 Choose the pattern that finds all filenames in which the first letters of the filename are astA, followed by a
digit, followed by the file extension .txt.
1) astA[[:digit:]]\.txt
2) astA[[0-9]].txt
3) astA.\.txt
4) astA[[:digit:]].txt
The answer of the above question is 2) astA[[0-9]].txt
In regular expressions, to specify the number between 0 to 9, we use the expression [0-9].
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q5 What's the difference between [0-z]+ and \w+ ?
1) The first one accepts 0 and z and the other doesn't.
2) The first one doesn't allow for uppercase letters.
3) The first one accepts more punctuation characters than the second one.
4) Nothing. They're identical.
The answer of the above question is 3) The first one accepts more punctuation characters than the second one.
\w stands for "word character", usually [A-Za-z0-9_]
where as n the case of [0-Z], this is equivalent to the following more readable character class [0-9:;<=>?@A-Z]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q6 What does the regular expression (\d{1,2}\/\d{1,2}\/\d{4} most likely represent?
1) An American ZIP code
2) A date
3) A phone number
4) A price
The answer of the above question is 2) A date
The \d{1,2}\ specifies that it can either be 1 or 2, the next set \d{1,2}\ also signifies 1 or 2.
The next \d{4} asks the user to enter the year which is not more than 9999.
Hence it is used for date.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q7 What does the regular expression [a-zA-Z0-9_]{3,14} most likely represent?
1) An e-mail address
2) A street address
3) A username
4) A set of X and Y coordinates
The answer of the above question is 3) A username
Since the letters can be a combinaiton of a-z A-Z or 0-9. {3,14} Gives the range where the min value is 3 and max value is 14.
so it can possibly be username, where it can be of minimum val 3 and maximum value 14.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q8 What does the regular expression ^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$
most likely represent?
1) A street address
2) A name
3) A time
4) A date
The answer of the above question is 3) A time
This part of the reg exp (0?[1-9]|1[012]) gives the hours the next part gives the mins :[0-5]\d){0,2}.
This part [AP]M) is used to define whether it is AM or PM.
This part ([01]\d|2[0-3])(:[0-5]\d){0,2}$ is being used to get the seconds and milliseconds.
Hence, this is the regular expression for a Time
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q10 What does the regular expression ^([0-3]|[0-9][0-9]|4[0-5][0-9]|46[0-6])$ most likely represent?
1) A range of numeric values from 0 to 499.
2) A range of numeric values from 399 to 499.
3) A range of numeric values from 399 to 466
4) A range of numeric values from 0 to 466.
The answer of the above question is 4) A range of numeric values from 0 to 466.
[0-3] gives a digit from 0-3
[0-9][0-9] gives 2 digits from 0-9 each
4[0-5][0-9] gives 3 digit, 1st digit is 4 always, 2nd can be form 0-5, 3rd digit can be from 0-9
46[0-6] gives 3 digits, where first 2 digits are 46 always, 3rd digit can be 0-6.
Hence, the minimum value is 0 and maximum value is 466.
Please upvote my answer if it helped you!!
please Answer the following regular expressions questions(also do number 9) Q4 Choose the pattern that finds...
In the program, the zipcode will be represented by an integer and the corresponding barcode will be represented by a string of digits. The digit 1 will represent the long bar, and the digit 0 will represent the short bar, The first and last digits of a POSTNET code are always 1. Stripping these leaves 25 digits, which can be split into groups of 5. The above example translates into the following string and groups of five: 101100100010010101100110001 01100 10001...
7. Lexical analyzer, is the first phase in compiler, Of what use is this to the whole compilation and 14 marks) what are the formal concepts involved ? 8. Describe this language using a Regular Expression: all strings beginning with a digit, followed 13 marks] by either a or b, and ending with an non-vowel uppercase letter 9. Write a context free granimar for the strings that consist of equal number of a's followed by equal number of b's. Attempt...
Finite state machines & Regular Expressions Please select the best option 1. For the following questions Let r, s, t be regular expressions for the same alphabet "á" (left column). Get the property on the right side that produces equality for each regular expression. 2. From the diagram of the solution M = (Σ, Q, s,, F) is respectively: e would be NONE. 3. The following graph corresponds to a diagram of: A. Transition machine and states b. Transition...
Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents. Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...
Some java questions: 18. Consider the following class definitions public class TestAB public static void main (String args) A bl new B() в ь2 -new B() ; b1.х, А.у, Ь2.х, в.у); System.out.printf ("%d, Sd, %d, d\n", class A public int x = 2; public static int y = 4; public A () ( X=y- class Bextends A public int x = 32; public static int y = 45; public B ( x ++y What is the result of attempting to...
3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...
help me with these problems and ill give you amazing ratings!! (must do all please) 7. Answer the following questions about continuity. (a) Write down the values of z at which the following function is discontinuous. If the function is continuous at every value of z, write 'Continuous Everywhere' f(a)1 (separate multiple values by commas) (b) Write down the values of z at which the following function is discontinuous. If the function is continuous at every value of z, write...
Please answer all of the following. The boxplot below shows the number of contacts in their cell by gender for my Spring 2018 statistics classes. Using the boxplot, answer the 4 questions below. Boxplot of CellNumbers 900 800 700 600 500 400 300 200 100 0 Male Female Gender CellNumbers Which distribution has 3 outliers? Which distribution appears skewed right, excluding 1. Male 1 outliers? 2. Female Which distribution is 1 3. Both less variable (has the smaller IQR)? 4....
MATLAB question. Please answer all the questions and also upload the code by MATLAB. Thanks. Down vote if no code provided. For the circuit shown above, at the moment t = 0, the switch is closed, find w(t) for 120, No energy is stored in the capacitor and inductor at moment t-0 1. Write the dynamic model for RLC circuit after t> 0? a. Show all vour work and calculations b. Write down the characteristic equation of the transfer function...
John and Jane Doe are married retired taxpayers who care for their three-year-old grandson. The following information was provided to you as documentation necessary to prepare their 2017 tax return. You will gather the appropriate information and complete the forms provided in Blackboard (1040, Schedule A, Schedule B and Schedule D) in preparation of their tax file. Please note that the forms provided may not match the tax year of the course, as IRS forms are not available until just...