Question

8.17 python a.) Write a regular expression pattern to match all words ending in s. b.)...

8.17 python

a.) Write a regular expression pattern to match all words ending in s.

b.) Write a regular expression pattern to match all words ending in ing.

c.) Write a regular expression pattern to match all words with ss anywhere in the string.

d.) Write a regular expression pattern to match all words beginning and ending with the letter a.

e.) Write a regular expression pattern to match all the words that start with st.

f.) Write a regular expression to match all the four-letter words where the middle two letters are vowels.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) "[a-zA-Z]+s\b" - [a-zA-Z] denotes any alphabetic character, + indicates one to many of those preceding types which in this case is alphabets, s\b indicates that the word ends with s

b) "[a-zA-Z]+ing\b" - [a-zA-Z] denotes any alphabetic character, + indicates one to many of those alphabets, ing\b indicates that the word ends with ing

c) "[a-zA-Z]*ss[a-zA-Z]*" - [a-zA-Z] denotes any alphabetic character, * indicates zero or more of those preceding types which in this case is alphabets, followed by ss followed by zero or more alphabets again

d) "\ba[a-zA-Z]*a\b" - \ba denotes a word starting with a, then zero or more alphabets and then a\b denotes a word ending with a

e) "\bst[a-zA-Z]*" - \bst denotes a word starting with st, then zero or more alphabets

f) "\b[a-zA-Z][aeiou][aeiou][a-zA-Z]\b" - first \b denotes a word starting boundary following by a character of alphabet in the range a-z or A-Z . This is following by two characters that are vowels denoted by[aeiou] which means any of these. and finally again a normal alphabet following by \b which denotes a word boundary in this case the word end. you can also use[aeiouAEIOU] for case insensitive vowels in the middle.

Add a comment
Know the answer?
Add Answer to:
8.17 python a.) Write a regular expression pattern to match all words ending in s. b.)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use the Python “re” module to do the following: 1. Write a regular expression pattern that matche...

    Use the Python “re” module to do the following: 1. Write a regular expression pattern that matches string “March 1, 2019, Mar 1, 2019, March First, 2019, March First, 19”. No credit for not using special characters: “*,+,?, | and etc” to do the matching. 2. Write a regular expression pattern that matches strings representing trains. A single letter stands for each kind of car in a train: Engine, Caboose, Boxcar, Passenger car, and Dining car. There are four rules...

  • IN PYTHON. We have seen examples of using the python re library. In this practice, you...

    IN PYTHON. We have seen examples of using the python re library. In this practice, you need to write python code and complete following tasks. (You can decide whether you want to define functions and how to organize your code. It is for your own practice.) 1). Define 10 string variables that follows the requirement given an integer, a float, a double, a float end with letter f (4.321f), Capital Letters( followed by small case letters, followed by digits, Exactly...

  • 4. Write regular expressions that match the descriptions given below. (10 P Description A sequence of...

    4. Write regular expressions that match the descriptions given below. (10 P Description A sequence of digits of any length that also contains the sequence of four letters "meow", in that order, anywhere in the Expression sequence. A sequence of zero or more x's and y's, OR zero or one z's. 3 The American word color, or the British spelling (colour). Your answer can NOT include an or. 4 A string that begins with an X and ends with an...

  • Write a regular expression that captures the set of strings composed of 'a', 'b', and 'c',...

    Write a regular expression that captures the set of strings composed of 'a', 'b', and 'c', where any string uses at most two of the three letters (for example, "abbab" is a valid string, or "bccbb", or "ccacaa", but not "abccba": strings that contain only one of the three letters are also fine). Give a non-deterministic finite automaton that captures the regular expression from Using the construction described in class, give a deterministic version of the automaton. Repeat the previous...

  • Preliminaries For this lab you will be working with regular expressions in Python. Various functions for...

    Preliminaries For this lab you will be working with regular expressions in Python. Various functions for working with regular expressions are available in the re module. Fortunately, Python makes it pretty easy to check if a string matches a particular pattern. At the top of the file we must import the re module: import re Then we can use the search() function to test whether a string matches a pattern. In the example below, the regular expression has been saved...

  • 3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa...

    3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...

  • Write a structured (procedural) Python program that solves the following spec: Soundex System Coding: Soundex is...

    Write a structured (procedural) Python program that solves the following spec: Soundex System Coding: Soundex is a system that encodes a word into a letter followed by three numbers that roughly describe how the word sounds. Therefore, similar sounding words have the same four-character code. Use the following set of (slightly modified #4) rules to create a translator from English words to Soundex Code: Retain the first letter of the word. For letters 2 …n, delete any/all occurrences of the...

  • Goal:   Unscramble permuted words by generating all permutations of Jumble string and searching for a word...

    Goal:   Unscramble permuted words by generating all permutations of Jumble string and searching for a word in Unix dictionary. Unix Dictionary: dict.txt Details: Write a method called get_permutations that inputs a string like "dog". Your method should return an array of all permutations of the Jumble string. . For example: s = "dog" perms = get_permutations(a) print(perms) Output: ['dog', 'dgo', 'odg', 'ogd', 'gdo', 'god'] Rewrite the script for obtaining permutations and the end of the Comments, Hints, and Observersions section...

  • Please use Python def findSubstrings(s):     # Write your code here Consider a string, s = "abc"....

    Please use Python def findSubstrings(s):     # Write your code here Consider a string, s = "abc". An alphabetically-ordered sequence of substrings of s would be {"a", "ab", "abc", "b", "bc", "c"}. If the sequence is reduced to only those substrings that start with a vowel and end with a consonant, the result is {"ab", "abc"}. The alphabetically first element in this reduced list is "ab", and the alphabetically last element is "abc". As a reminder: • Vowels: a, e, i,...

  • Python   #complete the following lines of code wherever indicated. 5 question 20 points a piece #you...

    Python   #complete the following lines of code wherever indicated. 5 question 20 points a piece #you may use your book and internet but no form of messaging or communication #QUESTION 1 #Read in the file exam_file.txt #Print to the console every other line #QUESTION 2 #Read in exam_file.txt #split file into words #write to a file called question2.out that contains 1 word per line (words can occur more than once) #QUESTION 3 # Print out all the Middle Initials in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT