Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-61

full regex support

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-2
    • 1.0-beta-4
    • None
    • None

    Description

      I know Sam mentioned this so I thought I'd raise a JIRA issue before I forgot.

      Hacking the parser so that /this|is|a|regexp/ could be embedded inside any groovy code (i.e. / followed by text ending in /) represents a regexp. Ruby uses this encoding mechanism. If that works out OK then we can support native regexp like Ruby & Perl.

      I'm thinking we should have some polymorphic new method like 'matches' which Object can support (which defaults to equals) but which things like Collections or Ranges can use 'contains' and things like regexp can mean 'matches'. Or Class could use matches to mean 'instanceof'

      Then switch statements could use 'matches' to allow neat switches...

      switch (foo) {
      case SomeClass:
      case 0..10:
      case /some|regex/:
      case [1, 4, 6]:
      }

      etc

      Attachments

        Activity

          People

            spullara Sam Pullara
            jstrachan James Strachan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: