Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2434

Emiting regexps in DSLs is unwieldy in the extreme

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Unresolved
    • Icon: Minor Minor
    • FUTURE
    • 5.0.1.FINAL
    • drools-compiler-DSL
    • None

      Any regexp emitted by a DSL must be octupled in order to pass through to the DRL and actually work in the rule.

      Example: I have a simple rule (I should say: a rule which SHOULD be simple), to test for emails:

      [condition][]is not email=not matches "^\\\\\\\\w-(\\\\\\\\.\\\\\\\\w-)@([a-z0-9-](\\\\\\\\.[a-z0-9-])?\\\\\\\\.[a-z]

      {2,6}

      |(\\\\\\\\d

      {1,3}\\\\\\\\.){3}\\\\\\\\d{1,3}

      )(:\\\\\\\\d

      {4}

      )?$"

      As you can see, each backslash is there 8 times. By then time it appears in the resulting DSL, they are doubled (which contrary to docs must be the case, otherwise the regexp does not behave correctly).

      Regular expressions should be treated differently throughout Drools. Maybe by using raw strings as in Perl or C#? It's really annoying...

            etirelli@redhat.com Edson Tirelli
            jjg.denis.robert Denis Robert (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

              Created:
              Updated:
              Archived: