Question

In: Computer Science

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.

Solutions

Expert Solution

Solution:

Regular Expression:

A regular expression is a set or a sequence of characters that can be used to detect the presence of a pattern.

These are generally used by string search and find algorithms.

In some cases where the input validation is needed, the regular expressions can be used.

In order to validate email id, the regular expression can be used.

The regular expression used for detecting the strings College and collegE is as follows.

^[Cc]olleg[Ee]$

Explanation:

^ represent the start character. The string must start with character c or C.

$ represent the end of string. The string must end with E or e.

The characters present in the middle must occur after c or C and before e or E.

Note:


Please see that as per the guidelines, only single question can be answered when multiple questions are present.

In case of multiple choice type questions, upto 4 can be answered. Thank you.

Please let me know in the comments section in case of any help needed.


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.
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output...
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output please. A blank line (may contain spaces) Postal abbreviation (2 letters) for State followed by a space and then the 5-digit zip code A KU student username (Ex. lpork247) A “valid” email address (also explain how you defined “valid”) A SSN pattern (ddd-dd-dddd)
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...
Unix / Linux 16. Regular Expression: Given the following regular expression, provide a description of the...
Unix / Linux 16. Regular Expression: Given the following regular expression, provide a description of the intended match. ^[^A-Z] 17. Regular Expression: Given the following regular expression, provide a description of the intended match. [^^!] 18. Regular Expression: Given the following regular expression, provide a description of the intended match. ^.\{72\}$ 19. Regular Expression: Given the following regular expression, provide a description of the intended match. [A-Za-z0-9] 20. Regular Expression: Given the following regular expression, provide a description of the...
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 #...
2. Write a Regular expression that matches words, where a word is a series of ASCII...
2. Write a Regular expression that matches words, where a word is a series of ASCII alphabetic characters. Match both upper- and lowercase. Note: Enter man grep to read about the options of grep. Answer:
Write a JAVA program that reads a text file into RAM efficiently, takes a regular expression...
Write a JAVA program that reads a text file into RAM efficiently, takes a regular expression from the user, and then prints every line that matches the RE.
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.
submit a regular expression that will identify each of the following patterns. 1 - a US...
submit a regular expression that will identify each of the following patterns. 1 - a US telephone number that conforms to the following pattern 111.222.3456 2 - a US social security number that fits the following pattern 111-22-3456 3 - an American Express credit card number that fits the following format:       4 digits followed by a space followed by 6 digits followed by a space followed by 5 digits False positives are allowed in each case, so all you need...
Consider the following regular expression meta operators: ( ) [ ] { } . * +...
Consider the following regular expression meta operators: ( ) [ ] { } . * + ? ^ $ | \ For each of the following, give one example of strings which the regular expression would match. Describe (colloquially, in a manner that a non-technical person would understand) the set of strings that the pattern is designed to match. Each regular expression is enclosed in the pair of '/' characters below. [2 marks each] (a) /^[a-z][0-9]*\.$/ (b) /([0-9]+)\s\w+\s\1/
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT