Question: JAVA 1. Write a regular expression that selects lines containing any of the following words: linux windows solaris macos . For this exercise you must

JAVA

1. Write a regular expression that selects lines containing any of the following words: linux windows solaris macos. For this exercise you must surround your solution with double quotes. Note: No it's not "^.*\b(linux|windows|solaris|macos)\b.*$"

2. Write a regular expression that selects lines containing a phone number. Assume a U.S./Canadian number with a 3-digit area code, a 3-digit exchange and another 4 digits. An additional extension is also possible. Assume that the phone number will have dashes or periods in the "usual" way: 718-951-5000 or 718.951.5000. Dashes and periods cannot be mixed. Also, the area code may be surrounded by parentheses: (718)-951-5000. Extensions, if present, will start with an X or an x, preceded by a space or nothing and followed by at least one and no more than four digits. Oh, and one other thing: area codes do NOT start with 0 or 1, do they? What a mess! (But somebody has to do it-- and that's you!) For this exercise you must surround your solution with double quotes .

Note: It's not "(\\([2-9]\\d{2}\\)||[2-9]\\d{2})(.\\d{3}.\\d{4}||-\\d{3}-\\d{4})(\\s[xX]\\d{1,4}||[xX]\\d{1,4}){0,1}"

3. Write a regular expression that selects lines containing the word shell. For this exercise you must surround your solution with double quotes .

Note: It's not "^.*shell.*$"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!