Question

In: Computer Science

Regular expression translation [ac7]b[bc] Translation: Match any 1 character in a set that is either a,...

Regular expression translation

  1. [ac7]b[bc]
    Translation: Match any 1 character in a set that is either a, c, or 7, then a b, then any 1 character that is in a set that is either b or c.
    Match example: abc
  2. ^…$
  3. \<the\>
  4. ^[A-Z]..$
  5. ^[A-Z][ a-z]*3[0-5]
  6. [a-z]*\.$
  7. ^ *[A-Z][a-z][a-z]$
  8. ^[A-Za-z]*[^,][A-Za-z]*$
  9. [[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}
  10. .*\([0-9][.][0-9]\)
  11. [0-9]{3}-[0-9]{4}

Solutions

Expert Solution

1. ^…$

in which ^ indicates start of the string and $ indicates end of the string. in between this two only three dots can possible can come

Example : ...

2. \<the\>

in which slashes are used to match < and >. In between these brackets the can only possible.

Example : <the>

3. ^[A-Z]..$

it will match any one character from A to Z and after that any two characters can possible, It may special characters, numbers, uppercase, lowercase etc..

Example

CcG
Q1R
Ri.
BA}
I>q

4. ^[A-Z][ a-z]*3[0-5]

means any one character from A to Z can set. After that, zero or more characters from a to z can be possible and 3 and then 1 character from 0 to 5.

Example : Basagsadbh35

5. [a-z]*\.$

In which any number of zero or more characters from a to z can be possible and \ is used to match . means after any number of characters there must be

.(dot). In short strings ends with .(dot)

Example : fhdjewvbafh.

6. ^ *[A-Z][a-z][a-z]$

means at space and * indicates any number of spaces can be possible. Then it will match 1 character from A to Z and then it will match 1 character from a to z and after that again it will match one character from a to z.

Example :

Bfg

Hyt

7. ^[A-Za-z]*[^,][A-Za-z]*$

Any characters from A to Z and a to z can be possible. [^,] means , can't possible and after that any number(zero or more) of characters from A to Z or a to z.

Example : sadjbsafjAdjfckdJGF

8. [[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}

[:digit:] any 3 characters from this set can be possible means [, ], :, d, g, i, t. And then .(dot) will come. then these will be repeating 3 times means any 3 characters from this set can be possible means [, ], :, d, g, i, t. And then .(dot) will come again any 3 characters from this set can be possible means [, ], :, d, g, i, t. And then .(dot) will come and again any 3 characters from this set can be possible means [, ], :, d, g, i, t. And then .(dot) will come.

Example :

d].[]]].t]]].g]]]

9. .*\([0-9][.][0-9]\)

.* menas strings can start with any chracter like special, uppercase, lowercase, digits etc.. \ is used to match opening bracket. After that ( (open bracket) will come and then any one digit from 0 to 9 will come then .(dot) and then again any digit from 0 to 9 can come. \ is used to match close bracket and ) will come at the end.

Example : !d5:7xwy(6.3)

10. [0-9]{3}-[0-9]{4}

In which any 3 characters from 0 to 0 will match then a -(hiphen) is possible. After that any 4 characters from 0 to 9 will be matched.

Example : 306-0552


Related Solutions

Write a regular expression, using the regular expression syntax used by lex, that matches any finite...
Write a regular expression, using the regular expression syntax used by lex, that matches any finite decimal representation of a nonnegative real number.
Question d) Write the regular expression statement that will match a string that starts with the...
Question d) Write the regular expression statement that will match a string that starts with the word "Warning" following by one space and then a number of any number of digits. Question e) Write the regular expression statement that will match a string that ends with the phrase "End of Report. Question f) Write the regular expression statement that will match a string that starts with the phrase "Begin Log:" then contains a collection of characters (other than newline) followed...
1. What is a regular expression? Write a regular expression that will detect “College” and “collegE”....
1. What is a regular expression? Write a regular expression that will detect “College” and “collegE”. 2. What is degree centrality? Create a graph of 4 vertices and compute the degree centrality of the vertices. 3. Compute internal and external community densities for a graph containing 6 nodes. You can create any graph of 6 nodes with at least 4 edges.
Q1 Write a python regular expression to match a certain pattern of phone number.             ###...
Q1 Write a python regular expression to match a certain pattern of phone number.             ### Suppose we want to recognize phone numbers with or without hyphens. The ### regular expression you give should work for any number of groups of any (non- ### empty) size, separated by 1 hyphen. Each group is [0-9]+. ### Hint: Accept "5" but not "-6" ### FSM for TELEPHONE NUMBER IS: # state:1 --[0-9]--> state:2 # state:2 --[0-9]--> state:4 # state:2 --[\-]---> state:3 #...
Define a regular expression that will correctly (and exactly) match a valid Gregorian calendar date of...
Define a regular expression that will correctly (and exactly) match a valid Gregorian calendar date of the form MM/DD/YYYY (with leading zeroes for single-digit months and days) (and ONLY dates in this format). • Months 1, 3, 5, 7, 8, 10, and 12 have 1–31 days • Months 4, 6, 9, and 11 have 1–30 days • Month 2 (February) has 1–28 days (ignore leap years) • Assume that the year falls into the range 1900–2099 HINT: You may find...
PYTHON Write a regular expression that will accept any properly formatted email address, and reject any...
PYTHON Write a regular expression that will accept any properly formatted email address, and reject any invalid email address. An example of a valid inputted email address would be "[email protected]".
Write a regular expression for the language of all strings over {a,b} in which every b...
Write a regular expression for the language of all strings over {a,b} in which every b is directly preceded by a, and may not be directly followed by more than two consecutive a symbols.
Using the pigeonhole theorem prove that any set of 220 10-character strings over the alphabet {a,b,c,d}...
Using the pigeonhole theorem prove that any set of 220 10-character strings over the alphabet {a,b,c,d} contains a pair of anagrams.
c program Evaluate the expression 1 && (30%10 >=0) && (30 %10<=3) Is either set of...
c program Evaluate the expression 1 && (30%10 >=0) && (30 %10<=3) Is either set of parentheses required? Write the complement of the expression two ways. First, add one operator and one set of parentheses. For the second version, use DeMorgan’s theorem.
Show using a direct proof and logical operators the following set equality.A−BC= A∩B
Show using a direct proof and logical operators the following set equality.A−BC= A∩B
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT