Question

In: Computer Science

You are given a task to parse through financial information and find the word “money” followed...

You are given a task to parse through financial information and find the word “money” followed by “bad” 2 or more times or “money” followed by “good” once. Create a regex that can search achieve this. You can ignore spaces. Legal words in the language could be “moneybadbadbad” or “moneygood”

Solutions

Expert Solution

The following is the code for above question. Here we used regex to solve the problem

import re
#input text to search for example
txt1="he is a moneybadbadbad boy"
txt2="he is a moneybad boy"
txt3="he is a moneygoodgood boy"
txt4="he is a moneygood boy"
#the word boundary \b is used for moneygood to match exactly once and badbad+ is used to match bad more than 2 times
x1=re.search(r'(\bmoneygood\b)|((money{1})badbad+)',txt1) 
x2=re.search(r'(\bmoneygood\b)|((money{1})badbad+)',txt2)
x3=re.search(r'(\bmoneygood\b)|((money{1})badbad+)',txt3)
x4=re.search(r'(\bmoneygood\b)|((money{1})badbad+)',txt4)
#print and test all matches
print(x1)
print(x2)
print(x3)
print(x4)

I am also attaching the output and code screenshot for your reference.

Output and code screenshot:

#Please don't forget to upvote if you find the solution helpful. Feel free to ask doubts if any, in the comments section. Thank you.


Related Solutions

Your task is to determine the WACC for a given firm using what you know about WACC, as well as data you can find through research.
(use a current ompany and data)Week Five Financial ExercisesYour task is to determine the WACC for a given firm using what you know about WACC, as well as data you can find through research. Your deliverable is a brief report in which you state your determination of WACC, describe and justify how you determined the number, and provide relevant information as to the sources of your data.Select a publicly traded company that has debt or bonds and common stock to...
Your task is to determine the WACC for a given firm using what you know about WACC as well as data you can find through research
Financial ExerciseYour task is to determine the WACC for a given firm using what you know about WACC as well as data you can find through research. Your deliverable is a brief report in which you state your determination of WACC, describe and justify how you determined the number, and provide relevant information as to the sources of your data.Select a publicly traded company that has debt or bonds and common stock to calculate the current WACC. One good source...
Your task is to find the value of a company stock. You have the following information:...
Your task is to find the value of a company stock. You have the following information: a) Investors expect 5 EUR dividend next year. b) Dividends are expected to stay constant for the next four years. c) However, dividends are expected to start growing 5% a year starting from year 5. d) Expected return from investments with comparable risk is 15%. Question: 1. Based on information above, what is the fundamentally justified price of a stock? 2. You observe that...
Your task is to find the value of a company stock. You have the following information:...
Your task is to find the value of a company stock. You have the following information: a) Investors expect 10 EUR dividend next week. Buying stock today entitles you to receive that dividend b) Dividends are expected to stay constant for the next three years. c) However, dividends are expected to start growing 3% a year starting from year 4. d) Expected return from investments with comparable risk is 13%. Question: 1. Based on information above, what is the fundamentally...
You have been given the task of evaluating and recommending a viable accounting information system for...
You have been given the task of evaluating and recommending a viable accounting information system for the accounting and financial data of your company. As you begin to research this system, you realize that many departments are involved in the information system. You decide that selecting a team to assist you with your research would be the most beneficial approach for the company. This module, you begin your course project by selecting a team to assist you in finding an...
Money Supply, Financial Policy and International trade (500 WORD LIMIT) The process of Creating Deposit Money...
Money Supply, Financial Policy and International trade (500 WORD LIMIT) The process of Creating Deposit Money is one of the most important things in the US and Global Economies, so ….u **** Define Money Creation, **** INCLUDING at least one (1) numerical example(s) of how it works, and EXPLAINING why it is so vitally important MUST and should be in 500 WORDS LIMIT **If you can't answer in 500 word limit then please don't answer because this is my second...
What is anti money laundering? What is the role of the Financial Action Task Force (FATF)?
What is anti money laundering? What is the role of the Financial Action Task Force (FATF)?
If you were going to invest money, given the current financial market status, where would you...
If you were going to invest money, given the current financial market status, where would you invest your money today? What are some possible investment choices for you as an individual? What factors influence your decision on what to invest in? How does the economic climate affect what you invest in?
Find information on the major financial markets in the US and also for the country you...
Find information on the major financial markets in the US and also for the country you have chosen. This would include discussions of stock markets (NYSE, NASDAQ, etc. in the US) and a description of the stock exchanges for the country you chose. Discuss the nature and size of these markets (for example, how many firms are listed on the exchange; how much is traded in monetary terms on each day). In addition, provide information on interest rates in the...
Early in 2010, Danielle, the chief financial officer for Sam Manufacturing, was given the task of...
Early in 2010, Danielle, the chief financial officer for Sam Manufacturing, was given the task of assessing the impact of a proposed risky investment on the firm’s stock value. To perform the necessary analysis, Danielle gathered the following information on the firm’s stock. During the immediate past 5 years (2005–2009), the annual dividends paid on the firm’s common stock were as follows: Year Dividend per share 2009 $2.90 2008 2.70 2007 2.55 2006 2.40 2005 2.30 Currently, the required return...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT