$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [Regex] Why doesn't this pattern match?
From: Vitalij Gotovskij (Vitalij.gotovskij_at_[hidden])
Date: 2009-12-08 06:07:51
>> Yes, Robert, You are right. I am trying to change \\n (wchar_t '\' and
>> wchar_t 'n') with a real new line symbols and it doesn't work. Allthought,
>> then I am trying to find only wchar_t 'n' (or any other letter) everything
>> is working good. The problem is that I have XML configuration file
>> (Unicode), where all new lines are L"\\n" (!!! not '\n' !!!). I can't
>> change that file format. Of course I can program that replace without
>> boost::regex, but I am afraid that I'll loose my sleep afterwards...
>>
>>>> You're replacing each occurrence of \\n with \\n, so the
>>>> string at the end should be exactly the same! :-)
>>
>>> The replacement is "\n" not "\\n" so the '\' followed by 'n' in str
>>> should be replaced with a newline, right?
> No. Remember the compiler gets first bite at the escape characters, so if
> you put a string "\\n" in your program, that gets passed to Boost.Regex as
> the two character string: "\n", which matches a single newline character.
> If you want to match a \ followed by a \n then you need a regex of "\\\n".
>HTH, John.
You wanted to say: "\\\\n" ? :) Anyway, thanks a lot. This works!
Didn't knew regex engine is working in that way... If he understands "\\\\n" as C++ "\\n"
and "\\n" as C++ understands "\n", then how regex engine understands "\n" ...?
Don't answer this letter. The problem is solved.