March 15, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12367

           Summary: std.regex: Recognize (?# ... ) comment syntax
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: thecybershadow@gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-15 02:11:29 EET ---
A comment syntax would be handy for particularly long expressions.

This syntax seems to be already supported by several existing engines: http://www.regular-expressions.info/freespacing.html#parenscomment

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 15, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12367


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2014-03-14 17:21:08 PDT ---
(In reply to comment #0)
> A comment syntax would be handy for particularly long expressions.
> 
> This syntax seems to be already supported by several existing engines: http://www.regular-expressions.info/freespacing.html#parenscomment

While it's good to have a basic (?# ... ) comment syntax, I much prefer the Python verbose regex syntax, because it allows me to lay down regexes as little programs, with logically indented lines and #-style comments:

http://docs.python.org/2/library/re.html

http://www.diveintopython.net/regular_expressions/verbose.html


>>> pattern = """
    ^                   # beginning of string
    M{0,4}              # thousands - 0 to 4 M's
    (CM|CD|D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
                        #            or 500-800 (D, followed by 0 to 3 C's)
    (XC|XL|L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
                        #        or 50-80 (L, followed by 0 to 3 X's)
    (IX|IV|V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
                        #        or 5-8 (V, followed by 0 to 3 I's)
    $                   # end of string
    """

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