Answer the question
In order to leave comments, you need to log in
How to make the correct output of the modified regular string?
There is a code:
#include<iostream>
#include<string>
#include<regex>
using namespace std;
int main()
{
string str; //объявление строки для изменения
cout<<"Enter string : ";getline(cin, str); //ввод строки
regex regular("(www.\\w+\\.\\w+)|(http""s?://""\\w+\\.\\w+)|(^[email protected]+\\..+$)");
cout<<"Modified string : "<<regex_replace(str, regular, " ***** ")<<endl; //вывод измененной строки
}
Answer the question
In order to leave comments, you need to log in
The output is just asterisks, it should change links like www.expamp.com, http(s)://example.com, and emails to stars.
.+$
one matches the string to the end. As written, it works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question