Re: [Regex] \r matching \n
Olaf van der Spek via Boost <[email protected]>
| Newsgroups | gmane.comp.lib.boost.devel |
|---|---|
| Message-ID | <CAGVGHmtyh6LRmopopCCc=A3TAgQhBjE2WqwMVeqdmX+NaGPtgQ@mail.gmail.com> |
On Wed, Mar 25, 2026 at 5:14 PM Rainer Deyke via Boost <[email protected]> wrote: > According to documentation > (https://www.boost.org/doc/libs/latest/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html): > > R"( > )" = "\n" should match itself, like all characters not in .[{}()\*+?|^$ > > R"(\n)" = "\\n" should match exactly '\n' and not '\r', just like "\n". > The documentation is explicit about this. > > R"(\r)" = "\\r" should match '\r', as should "\r", for what it's worth. > > R"(\\n)" = "\\n" should match "\\n", i.e. a backslash followed by 'n'. This line isn't correct, is it? Two slashes in the raw string should be four slashes in a normal string. > '$' should match the end of a line, including embedded newlines in the > text. It is not clear what qualifies as a newline in this sense, but > I'm guessing '\r' might qualify. Yeah, this makes sense. Also depends on the m modifier: > Normally Boost.Regex behaves as if the Perl m-modifier is on: so the assertions ^ and $ match after and before embedded newlines respectively, setting this flags is equivalent to prefixing the expression with (?-m). I thought ^ and $ would be begin and end of input by default, but it's the other way around. -- Olaf _______________________________________________ Boost mailing list -- [email protected] To unsubscribe send an email to [email protected] https://lists.boost.org/mailman3/lists/boost.lists.boost.org/ Archived at: https://lists.boost.org/archives/list/[email protected]/message/DLNFDZXYCJHL52HUGLI6LFD46K3EJVNW/