www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7674] New: regex replace requires escaped format

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7674

           Summary: regex replace requires escaped format
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: Jesse.K.Phillips+D gmail.com
                CC: dmitry.olsh gmail.com


--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D gmail.com> 2012-03-08
14:10:44 PST ---
When using std.regex.replace the format parameter is also requiring to be a
valid regex. The below example is expected to pass

import std.regex;

void main() {
    auto str = "hello?";

    assert(str.replace(regex(r"\?", "g"), r"\?") == r"hello\?");
}

This should fail:

import std.regex;

void main() {
    auto str = "hello?";

    assert(str.replace(regex(r"\?", "g"), r"\\?") != r"hello\?");
}

Maybe I'm wrong on this, but the current requirement seems off.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 08 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7674



--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2012-03-09
03:30:45 PST ---
(In reply to comment #0)
 When using std.regex.replace the format parameter is also requiring to be a
 valid regex.

But speaking of format string it is expected to be a plain string there is no need to escape a thing in there IRC. The below example is expected to pass
 
 import std.regex;
 
 void main() {
     auto str = "hello?";
 
     assert(str.replace(regex(r"\?", "g"), r"\?") == r"hello\?");
 }
 
 This should fail:
 
 import std.regex;
 
 void main() {
     auto str = "hello?";
 
     assert(str.replace(regex(r"\?", "g"), r"\\?") != r"hello\?");
 }
 
 Maybe I'm wrong on this, but the current requirement seems off.

-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7674



--- Comment #2 from github-bugzilla puremagic.com 2012-03-17 11:04:23 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/097faaca84b0d8f4031cc56721ec846ff4bd6a6e
fix Issue 7674 - regex replace requires escaped format

Kill unnecessary escaping in replace format string.

https://github.com/D-Programming-Language/phobos/commit/bdaa3260ffe62237d7360e84f8e6f01b30e4ab54
changelog entry for issue 7674

https://github.com/D-Programming-Language/phobos/commit/55debbccd020059aec0764cbcbd1773c3a85fe73
Merge pull request #492 from blackwhale/issue-7674

Issue 7674 - regex replace requires escaped format

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 17 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7674


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 22 2012