glazedlists
  1. glazedlists
  2. GLAZEDLISTS-509

[bug found and correction proposed] How the regular-expression works?

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.9.1
    • Fix Version/s: milestone 1
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      509

      Description

      Excuse me, but I have tried the whole afternoon to make work the following:
      matcherEditor.setMode(TextComponentMatcherEditor.REGULAR_EXPRESSION);

      Without success.

      Could anyone tell me how it works?

        Activity

        Hide
        revever added a comment -

        I think it's a BUG.

        In the method 'indexOf' of class 'RegularExpressionTextSearchStrategy', the
        following always returns 'false':
        >> matcher.reset(text).matches()

        In fact, I have created a custom strategy, and replaced the above line by:
        >> matcher.reset(text).find()
        That works.

        Show
        revever added a comment - I think it's a BUG. In the method 'indexOf' of class 'RegularExpressionTextSearchStrategy', the following always returns 'false': >> matcher.reset(text).matches() In fact, I have created a custom strategy, and replaced the above line by: >> matcher.reset(text).find() That works.
        Hide
        brands added a comment -

        The following tests succeed, so matcher.reset(text).matches() doesn't always
        return false:

        public void testIndexOf()

        { RegularExpressionTextSearchStrategy strategy = new RegularExpressionTextSearchStrategy(); strategy.setSubtext("[a-z]"); assertEquals(0, strategy.indexOf("a")); }

        public void testMultipleMatches()

        { RegularExpressionTextSearchStrategy strategy = new RegularExpressionTextSearchStrategy(); strategy.setSubtext("[a-z] [a-z] [a-z] [a-z]"); assertEquals(0, strategy.indexOf("a b c d")); }

        public void testPartialMatch()

        { RegularExpressionTextSearchStrategy strategy = new RegularExpressionTextSearchStrategy(); strategy.setSubtext("[a-z] "); assertEquals(-1, strategy.indexOf("a b c d")); }

        You should ask about this on the user list, perhaps the original author will
        comment on the chosen implementation.

        Show
        brands added a comment - The following tests succeed, so matcher.reset(text).matches() doesn't always return false: public void testIndexOf() { RegularExpressionTextSearchStrategy strategy = new RegularExpressionTextSearchStrategy(); strategy.setSubtext("[a-z]"); assertEquals(0, strategy.indexOf("a")); } public void testMultipleMatches() { RegularExpressionTextSearchStrategy strategy = new RegularExpressionTextSearchStrategy(); strategy.setSubtext("[a-z] [a-z] [a-z] [a-z]"); assertEquals(0, strategy.indexOf("a b c d")); } public void testPartialMatch() { RegularExpressionTextSearchStrategy strategy = new RegularExpressionTextSearchStrategy(); strategy.setSubtext("[a-z] "); assertEquals(-1, strategy.indexOf("a b c d")); } You should ask about this on the user list, perhaps the original author will comment on the chosen implementation.
        Hide
        revever added a comment -

        Interesting tests! In fact, the 'find' is more tolerant than the 'matches':
        -----------------
        // this will FAIL
        public void testMatches()

        { Matcher matcher = Pattern.compile("a").matcher(""); assertTrue(matcher.reset("abc").matches()); }

        // this PASS
        public void testFind()

        { Matcher matcher = Pattern.compile("a").matcher(""); assertTrue(matcher.reset("abc").find()); }

        ------------------------

        Back to the GL filter, if a user input 'a' in the filter TextField, no item
        will match. The user must input 'a.*' to see the results. (not very
        comfortable, no?)

        But if in 'RegularExpressionTextSearchStrategy', we use
        >>matcher.reset(text).find()
        either 'a' or 'a.*' works.

        So I think 'find' will be more user-friendly.

        Show
        revever added a comment - Interesting tests! In fact, the 'find' is more tolerant than the 'matches': ----------------- // this will FAIL public void testMatches() { Matcher matcher = Pattern.compile("a").matcher(""); assertTrue(matcher.reset("abc").matches()); } // this PASS public void testFind() { Matcher matcher = Pattern.compile("a").matcher(""); assertTrue(matcher.reset("abc").find()); } ------------------------ Back to the GL filter, if a user input 'a' in the filter TextField, no item will match. The user must input 'a.*' to see the results. (not very comfortable, no?) But if in 'RegularExpressionTextSearchStrategy', we use >>matcher.reset(text).find() either 'a' or 'a.*' works. So I think 'find' will be more user-friendly.

          People

          • Assignee:
            jessewilson
            Reporter:
            revever
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: