Question

In: Computer Science

Regular expressions are used in Python for describing and identifying specific patterns. In Python, we use...

Regular expressions are used in Python for describing and identifying specific patterns. In Python, we use “re” or “Regex” to denote regular expressions.

  1. Write the Python Code to return matching analytics word in the following given text.
  2. Write the Python Code to return how many times analytics word is provided in this text.

Definitions are useful to the extent they serve a purpose. So, is defining analytics important?

Yes and no. It’s not likely that we’ll ever arrive at a conclusive definition of analytics, but discussing what is and isn’t within its realm provides cohesive boundaries; boundaries that can help analytics emerge as an academic discipline, a field of business or a career. We cogently talk about mathematics even though it covers many varied topics. Analytics hasn’t quite reached that point. Understanding its boundaries can help people considering analytics appreciate what they’re getting into. In particular, it can help companies wanting to pursue analytics understand what will work best in their business. This is especially important given that the growth of analytics is leading consultants and software vendors, many of whom don’t fully grasp what analytics can offer, to jump into the fray.

Source: http://analytics-magazine.org/profit-center-what-is-analytics/

Solutions

Expert Solution

code:

import re

def main():

text = '''Definitions are useful to the extent they serve a purpose. So, is defining analytics important?

Yes and no. It’s not likely that we’ll ever arrive at a conclusive definition of analytics, but discussing what is and isn’t within its realm provides cohesive boundaries; boundaries that can help analytics emerge as an academic discipline, a field of business or a career. We cogently talk about mathematics even though it covers many varied topics. Analytics hasn’t quite reached that point. Understanding its boundaries can help people considering analytics appreciate what they’re getting into. In particular, it can help companies wanting to pursue analytics understand what will work best in their business. This is especially important given that the growth of analytics is leading consultants and software vendors, many of whom don’t fully grasp what analytics can offer, to jump into the fray.'''

matches = re.findall("analytics",text,re.IGNORECASE)

print("Analytics word matches :")

for match in matches:

print(match)

print("Total number of analytics words present in text : ",len(matches))


main()


Related Solutions

Understanding RegEx to identify patterns of data. 1. Create 4 regular expressions to filter a specific...
Understanding RegEx to identify patterns of data. 1. Create 4 regular expressions to filter a specific data set. 2. In addition to the description, provide two test cases that will pass the input and one that will fail
Understanding RegEx to identify patterns of data. Create 10 regular expressions to filter a specific data...
Understanding RegEx to identify patterns of data. Create 10 regular expressions to filter a specific data set and explain what they each do.
RegEx (Regular Expressions) Make 8 regular expressions to filter a specific data set in Java and...
RegEx (Regular Expressions) Make 8 regular expressions to filter a specific data set in Java and explain what they do.
Using Python, Regular Expressions, .map() and other functions as appropriate to format existing address records and...
Using Python, Regular Expressions, .map() and other functions as appropriate to format existing address records and eliminate records with missing critical fields.Critical fieldsincludeFirstName, Lastname, Zipcode+4, and Phone number for customers. For this exercise, create an array to hold data with these 4 fields containing at least 25records. The Zipcode field should contain either traditional 5-digit Zipcode(e.g. 21801)or Zip+4 format(e.g 21801-1101). The phone numbers should contain 10-digit (e.g. 5555555555)or formatted 10-digit(e.g. 555-555-5555). Some records might be corrupt so the data needs...
linux: Regular expressions file name: studentsyslog.txt Use a regular expression and grep or egrep to filter...
linux: Regular expressions file name: studentsyslog.txt Use a regular expression and grep or egrep to filter the file so the output displays only the items requested. Put your full command in the space provided 1.Show only the lines that end with an ellipses (3 dots) :
linux: regular expressions file name: studentsyslog.txt Use a regular expression and grep or egrep to filter...
linux: regular expressions file name: studentsyslog.txt Use a regular expression and grep or egrep to filter the file so the output displays only the items requested. Put your full command in the space provided. 1. Display only the lines that were written to the file between the times of 12:55 and 12:59 (inclusive). This is tricky. Don’t think of these times as numbers, think of these times as a series of characters (a 1 followed-by a 2 followed-by a colon,...
linux: regular expressions file name: studentsyslog.txt Use a regular expression and grep or egrep to filter...
linux: regular expressions file name: studentsyslog.txt Use a regular expression and grep or egrep to filter the file so the output displays only the items requested. Put your full command in the space provided. 1. Display only the lines that were written to the file between the times of 12:55 and 12:59 (inclusive). This is tricky. Don’t think of these times as numbers, think of these times as a series of characters (a 1 followed-by a 2 followed-by a colon,...
In this assignment, we will explore some simple expressions and evaluate them. We will use an...
In this assignment, we will explore some simple expressions and evaluate them. We will use an unconventional approach and severely limit the expressions. The focus will be on operator precedence. The only operators we support are logical or (|), logical and (&), less than (<), equal to (=), greater than (>), add (+), subtract (-), multiply (*) and divide (/). Each has a precedence level from 1 to 5 where higher precedence operators are evaluated first, from left-to-right. For example,...
Write a python programA3) Lambda Expressions. Use lambda expression to sort the list ["democratic", "republican", "equal",...
Write a python programA3) Lambda Expressions. Use lambda expression to sort the list ["democratic", "republican", "equal", "python", "break", "two", "ruby"] by: a) the last 2 characters of each list item in reverse order b) create new list from list above where each item has only 3 characters and first one is capitalized. For example, the list item = "democratic" will transform into "Dem". Apply alphabetically sorting to the new list.  
In planning an audit, the use of analytical procedures may be used to assist in identifying...
In planning an audit, the use of analytical procedures may be used to assist in identifying and assessing the risks of material misstatement. The following information pertains to Dough Ball Ltd one of your audit clients. They bake bread products which it supplies to numerous supermarkets and petrol station shops. The company operates from one central bakery and uses a fleet of vans to deliver to its customers. Minimal inventory is held at any time. The company employs a small...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT