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

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)
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 #...
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...
Write the correct regular expression pattern for a phone number field with the format XXX-XXX-XXXX
Write the correct regular expression pattern for a phone number field with the format XXX-XXX-XXXX
Pattern matching using python3 re module Write a regular expression that will find out all the...
Pattern matching using python3 re module Write a regular expression that will find out all the words that ends with 4 consecutive vowels at the end. Example: import re f=open("/usr/share/dict/american-english",'r') pattern='a[a-z]*d$' words=f.readlines() matchlist=[word for word in words if re.match(pattern,word)] =============================== Generate random string follow a specific pattern You will take a username and ask user for the password. User has to enter a strong password in order to create his or her account. The criteria for strong password is, a)...
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/
write a regular expression that will, using capturing groups, find: last name first name middle name...
write a regular expression that will, using capturing groups, find: last name first name middle name (if available) student ID rank home phone work phone (if available) email program (i.e., S4040) grade Replace the entire row with comma-delimited values in the following order: first name,middle name,last name,program,rank,grade,email,student ID,home phone,work phone Example substitution string for the first student Jane,V,Quinn,S4040,SO,B,[email protected],Q43-15-5883,318-377-4560,318-245-1144,Y
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT