Question

What is a potential regex solution for an Array that contains these lines to find the...

What is a potential regex solution for an Array that contains these lines to find the first names and last names? (PYTHON)

John Doe

John, E. Doe

John, Doe E.

John, Doe

Jo hn, Doe Jr. (first name is "Jo hn")

John, Doe Doe III

John, E Doe

Homework Answers

Answer #1
^([a-zA-Z]{2,}\s[a-zA-Z]{1,}'?-?[a-zA-Z]{2,}\s?([a-zA-Z]{1,})?)

^                             // start of line
[a-zA-Z]{2,}    // will except a name with at least 2 characters
\s             // will look for blank space between name and surname
[a-zA-Z]{1,} // needs at least 1 Character
\'?-?               // possibility of **'** or **-** for double barreled and hyphenated surnames
[a-zA-Z]{2,}    // will except a name with at least 2 characters
\s?            // possibility of another whitespace
([a-zA-Z]{1,})? // possibility of a 2nd surname

Know the answer?
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
Similar Questions
7. A mineral contains lithium chromate and other inert compounds. In order to find out what...
7. A mineral contains lithium chromate and other inert compounds. In order to find out what the percent mass of lithium chromate is in the mineral you dissolve 6.294g of the mineral in water and add iron(III) nitrate to the solution. A solid forms and you continue to add iron(III) nitrate until the solid stops forming. You filter the solution, dry the solid you obtained and measure that the mass of solid formed is 1.596 g. What is the percent...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b,...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b, where a – b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a – b = 3 A = [10, 4, 6, 16, 1, 6, 12, 13] Then your method should return the following pairs: 4, 1 15, 12 13, 10 A poor solution: There are...
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
**please write code with function definition taking in input and use given variable names** for e.g....
**please write code with function definition taking in input and use given variable names** for e.g. List matchNames(List inputNames, List secRecords) Java or Python Please Note:    * The function is expected to return a STRING_ARRAY.      * The function accepts following parameters:      *  1. STRING_ARRAY inputNames      *  2. STRING_ARRAY secRecords      */ Problem Statement Introduction Imagine you are helping the Security Exchange Commission (SEC) respond to anonymous tips. One of the biggest problems the team faces is handling the transcription of the companies reported...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all user information from a given input file. The input file contains information of a user in following order: username, first name, last name, password, account number and account balance. Information is separated with ‘|’. o username is a unique information, so no two users will have same username. Sample input file: Username eaglebank has password 123456, account number of BB12 and balance of $1000....
Instructions​: You will find a file named findingNemo.m and another named nemo.txt. The first contains code...
Instructions​: You will find a file named findingNemo.m and another named nemo.txt. The first contains code which will read in strings from nemo.txt, then call Lab08(string) on each line of nemo.txt. Your job is to write Lab08.m. The Lab08 function will take in a string as input and will return an integer n as output. The value of n will be the nth word in the input string, where n is the location of the substring 'Nemo'. Please note that...
HIMT 345 Homework 06: Iteration Overview: Examine PyCharm’s “Introduction to Python” samples for Loops. Use PyCharm...
HIMT 345 Homework 06: Iteration Overview: Examine PyCharm’s “Introduction to Python” samples for Loops. Use PyCharm to work along with a worked exercise from Chapter 5. Use two different looping strategies for different purposes. Prior Task Completion: 1. Read Chapter 05. 2. View Chapter 05’s video notes. 3. As you view the video, work along with each code sample in PyCharm using the Ch 5 Iteration PPT Code Samples.zip. Important: Do not skip the process of following along with the...
The car dealer has all of their inventory housed in the array seen below. Scroll down...
The car dealer has all of their inventory housed in the array seen below. Scroll down past the data to find out how you can help the car dealer. let inventory = [ { id: 1, car_make: "Lincoln", car_model: "Navigator", car_year: 2009 }, { id: 2, car_make: "Mazda", car_model: "Miata MX-5", car_year: 2001 }, { id: 3, car_make: "Land Rover", car_model: "Defender Ice Edition", car_year: 2010 }, { id: 4, car_make: "Honda", car_model: "Accord", car_year: 1983 }, { id: 5,...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
Answer the following questions from the information below a. What are the organization's marketing goals? b....
Answer the following questions from the information below a. What are the organization's marketing goals? b. What are the symptoms of the problem? In other words, which of the organization's marketing goals mentioned in section a., above are not being met? c. What is the organization's problem? Look at the symptoms and make a judgement about what their cause may be. Do not confuse symptoms with problems. Problems cause symptoms. d. Perform a SW/OT analysis: -What are the organization's internal...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT