Question: Python import re and use regex Replace the word Boy/Girl or boy/girl with Man/Woman. 1. Boy/Girl or boy/girl should be replaced with Man/Woman if the

Python import re and use regex

Replace the word Boy/Girl or boy/girl with Man/Woman.

1. Boy/Girl or boy/girl should be replaced with Man/Woman if the word prior to it is a name (starts with a capital letter)

Here are some examples:

Spider Girl, I need help!

Should return

Spider Woman, I need help!

There is a boy trapped in a burning building Iron Boy

Should return

There is a boy trapped in a burning building Iron Man

This is because the first boy is not proceeded by a word that has a Capital letter

Be careful not to return extra spaces in the final output. You may need to do a little bit of extra processing of the string captured by your group to ensure this. You will receive partial credit for having unwanted spaces. Please remove extra spaces for full credit.

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!