#include <regex>
#include <string>
#include <iostream>
int main(void) {//u2d?
        
std::cout<<std::regex_replace("abcdefghiabcdefghi",std::regex("def",std::regex_constants::extended),"CODE")
        <<" should have CODE twice in the string."<<std::endl;

        
std::cout<<std::regex_replace("abcd\r\nefghiabcdefghi",std::regex("\n",std::regex_constants::extended),"CODE")
        <<" should have CODE\nefg... twice in the string."<<std::endl;

        
std::cout<<std::regex_replace("abcd\r\nefghiabcdefghi",std::regex("\r\n",std::regex_constants::extended),"CODE")
        <<" should have abcdCODEefg... twice in the string."<<std::endl;

        
std::cout<<std::regex_replace("abcd\r\nefghiabcdefghi",std::regex("\\n",std::regex_constants::extended),"CODE")
        <<" should have CODE twice in the string."<<std::endl;
        //for some reason, throws regex error at runtime about unexpected 
escape.
        //should not complain about having a backslash then n in the search-for.
        return 0;
}


performs a mostly correct set of replaces except for last. hope it helps.
could be used in u2d since windows/dos use \r\n which is technically
correct for older terminals like ADM-3A. look up the termcaps yourself if
you would like. DEC VT-100 also, VT-102.


the header wording on the cppreference page is not right, should be more
like that of cplusplus.com's reference area. the point of regex_match is
not to match the entire target string, but to match whatever portion of it
is appropriate. for instance, using ^$ or not, or the full string without
^$. I just hope it works with carriage returns correctly. more testing. I
posted a talk there that solves the problem.

http://www.cplusplus.com/reference/regex/regex_match/
http://www.cplusplus.com/reference/regex/regex_replace/

I don't like trolling.

apparently std::regex_replace doesn't like \\ in a C++ string.



On Fri, November 4, 2016 8:29 pm, NightStrike wrote:
> On Fri, Nov 4, 2016 at 11:37 PM, Jim Michaels
> <[email protected]> wrote:
>
>> that page's description of regex_match has got to be wrong. what good
>> use is there to match the entire line to the regex? seriously, think
>> about it. I would substitute the abiguous term "target" for some other
>> more specific variable name listed below.
>
> Ok, you're either extremely confused, or simply trolling.  Either way,
> I can't help you any longer.  Please take your misunderstandings of
> C++ elsewhere.
>
>
> -------------------------------------------------------------------------
> -----
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
>


-- 
Jim Michaels
[email protected]


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to