Question

In: Computer Science

THE NOT REPLACE PROBLEM Must use loops. Please do not use sequence of if statements. I...

THE NOT REPLACE PROBLEM

Must use loops. Please do not use sequence of if statements.

I need it in C++.

Given an input string, set result to a string where every appearance of the lowercase word "is" has been replaced with "is not". The word "is" should not be immediately preceded or followed by a letter -- so for example the "is" in "this" does not count.  

• for input of "is test" → "is not test"

• for input of "is-is" → "is not-is not"

• for input of "This is right" → "This is not right"

Solutions

Expert Solution

PROGRAM :

#include <iostream>
#include <string>
// importing regex module for regular expression
#include <regex>

using namespace std;

int main() {
string text;
cout << "Please enter the input string : ";
// getline() to input a string ot a sentence
getline(cin,text);
// \b acts as word boundary
// regex variable 'e' is initialized based on the question which matches for 'is' inside any statement
std::regex e("\\b(is)\\b");
// replace 'is' with 'is not'
cout<<"The replaced string is : " + std::regex_replace(text,e,"is not");
}

OUTPUT :


Related Solutions

THE STRING MATCH PROBLEM C++ only. Must use loops. Please do not use sequence of if...
THE STRING MATCH PROBLEM C++ only. Must use loops. Please do not use sequence of if statements. . Given 2 strings, a and b, set result to the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings. • for input of "xxcaazz", "xxbaaz" → 3 • for input of "abc", "abc" → 2 • for input...
CODE MUST BE IN C++ (please use for loop) write a program that loops a number...
CODE MUST BE IN C++ (please use for loop) write a program that loops a number from 1 to 10 thousand and keeps updating a count variable (count variable starts at 0 ) according to these rules: n1 = 14 n2 = 54 n3 = 123 if the number is divisible by n1, increase count by 1 if the number is divisible by n2, increase count by 2 if the number is divisible by n3, increase count by 3 if...
YOU MUST USE SWITCH STATEMENTS TO SOLVE THE NEXT TWO PROBLEMS. NO LOOPS ALLOWED we have...
YOU MUST USE SWITCH STATEMENTS TO SOLVE THE NEXT TWO PROBLEMS. NO LOOPS ALLOWED we have not covered them yet therefore we can't use them Write a program that displays the following menu: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display...
C++ Please Do not use loops!! Assignment : Dice Roll Redux In "Dungeons & Dragons" and...
C++ Please Do not use loops!! Assignment : Dice Roll Redux In "Dungeons & Dragons" and similar role-playing games, dice with different numbers of sides are used to determine the outcomes of events throughout the game. There are different dice for different occasions: 4-sided, 6-, 8-, 10-, 12-, and 20-sided dice are common. A required roll is typically designated <n>d<s> where <n> is the number of dice to throw and <s> is the number of sides on those dice. For...
Objectives To reinforce the use of If-Else statements To learn how to use while loops Introduction:...
Objectives To reinforce the use of If-Else statements To learn how to use while loops Introduction: Mission to Mars Your friend has been playing a new Mars Colony simulator nonstop! They are always talking about how cool it would be if they could be a on the first real-life mission to Mars! To amuse your friend, you have decided to create a series of programs about the possible first colony on Mars. Problem: Where Can We Get the Best Deal?...
MUST USE LOOPS. Write a perl program that replicates the actions of a pez dispenser. The...
MUST USE LOOPS. Write a perl program that replicates the actions of a pez dispenser. The program should print out the contents of the dispenser showing that it is empty, prompt a user for 10 pez candy flavors/colors, print out the contents of the dispenser showing that it is full, dispense the candies one at a time, and then print out the contents of the dispenser showing that it is empty. The dispenser should only take in 10 candies and...
please do this in C++! I want to understand it, it must be done before the...
please do this in C++! I want to understand it, it must be done before the evening or nightime. Follow instructions exactly as it says. Please send a screenshot also with your code so I can see how it is supposed to be formatted. Since typing it a chegg answer, makes it look a bit messy. Your program will read in a file of commands. There are three types of commands: Warrior creates a new warrior with the specified name...
Please do the math by hand, do not use a program, I need to see the...
Please do the math by hand, do not use a program, I need to see the procedure, the answer itself is less important. Comparison of peak expiratory flow rate (PEFR) before and after a walk on a cold winter's day for a random sample of 9 asthmatics. Use the following data to determine if the patients conditioned changed after a walk. Present your results and make some interpretations. Subject Before After 1 312 300 2 242 201 3 340 232...
In the given instruction, I am to use while loops only. The goal is to prompt...
In the given instruction, I am to use while loops only. The goal is to prompt the user to select an acceptable input. If the wrong input is given, the program forces the user to select an appropriate input. The program also keeps running until the user chooses to exist by selecting a very specific input which in my case is the upper or lower case "E". The problem is even after selecting upper or lower case "E", my program...
Ali has 100 jobs that he must do in sequence, with the times required to do...
Ali has 100 jobs that he must do in sequence, with the times required to do each of these jobs being independent random variables with mean 1.3 minutes and standard deviation 3.0 minutes. Aysun has 200 jobs that she must do in sequence, with the times required to do each of these jobs being independent random variables with mean 1.0 minutes and standard deviation 2.3 minutes. Note that the time required for Ali to do any of his jobs is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT