Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following: 1. Using the basic Perl Syntax, write a single regular expression (not a whole program) that would replace all occurrences of numbers

Complete the following:

1. Using the basic "Perl Syntax", write a single "regular expression" (not a whole program) that would replace all occurrences of numbers in the form 1234567890 (any 10 consecutive digits, but only 10) in a file with the same digits in the following format: (123) 456-7890

2.

Using regular expressions, write a complete Perl script that, when given the input from a sample as shown below, displays ONLY the valid phone numbers found anywhere in the file. For this example assume a phone number is valid only if it is in the following form (where 9 represents any number):

(999)-999-9999

Sample Input:

this is a test 12345676867 (123)-456-7890 My number: (123)-555-1212 test 9999 test. A phone number ((123)-999-0000) exists on this line. There is no phone number ((123)-999+0000) on this line.

Sample Output:

(123)-456-7890 (123)-555-1212 (123)-999-0000

3.

Write a single Perl or Python program to count and display the number of occurrences of words which contain 4 consecutive vowels. (Vowels include a,e,i,o,u,y). The input should be readable from a "input pipe" (as in <cat or type> somefile.txt | <perl or python> program_name). Note that the input just has one word on each line:

Fake Example input:

abcdef

aeiou

zaeyiax

abecixoxu

(The bolded letters are shown here only for illustration.)

Example Output:

aeiou

zaeyiax

Found 2 matches

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions