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 #...
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.
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
Find the (a) amplitude, (b) period, (c) phase shift (if any), (d) vertical translation(if any), and...
Find the (a) amplitude, (b) period, (c) phase shift (if any), (d) vertical translation(if any), and (e) range of each function. then graph the function over at least one period. 1) y=-1/4 sin(3/4x+180degrees/8) 2)y=-3+3sin1/2x 3)y=2/3cos(x=180degrees/2)
Passwords of length 10 are formed using the character set S = {a, b, c, …,...
Passwords of length 10 are formed using the character set S = {a, b, c, …, z, A, B, …, Z, 0, 1, 2, .., 9}. Thus the set S consists of 62 different characters. For each part below, you must include a few words that describe your counting strategy. (a) How many passwords of length 10 use the character Q exactly two times? (b) How many passwords of length 10 use at most one of the “upper case” letters...
Write a regular expression that can represent any digit, without more than one digit or non...
Write a regular expression that can represent any digit, without more than one digit or non digit characters.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT