Write a function called substring that uses the leftmatch and rightmatch functions developed in Exercises 3 and 4 to remove a pattern from the left and right side of a value. It should take three arguments as shown:

$ substring /usr/ /usr/spool/uucppublic /uucppublic
spool
$ substring s. s.main.c .c
main
$ substring s. s.main.c .o Only left match
main.c
$ substring x. s.main.c .o No matches
s.main.c
$

# substring leftpat value rightpat
#
# remove leftpat, then rightpat from value

leftpat=$1
value=$2
rightpat=$3

newvalue=$(sh leftmatch $leftpat $value)

sh rightmatch $newvalue $rightpat

Computer Science & Information Technology

You might also like to view...

Marking a workbook as final makes the workbook _______, discouraging a user from making any changes to it.

A. write-only B. read-only C. locked D. protected

Computer Science & Information Technology

To create a view definition, use the ____________________ command.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology