Changeset 6455 in josm


Ignore:
Timestamp:
2013-12-07T22:38:45+01:00 (11 years ago)
Author:
simon04
Message:

fix #7939 - MapCSS: add support for negated regular expressions

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r6070 r6455  
    6464    public static enum Op {
    6565        EQ, NEQ, GREATER_OR_EQUAL, GREATER, LESS_OR_EQUAL, LESS,
    66         REGEX, ONE_OF, BEGINS_WITH, ENDS_WITH, CONTAINS;
     66        REGEX, NREGEX, ONE_OF, BEGINS_WITH, ENDS_WITH, CONTAINS;
    6767
    6868        public boolean eval(String testString, String prototypeString) {
     
    7575                return !equal(testString, prototypeString);
    7676            case REGEX:
     77            case NREGEX:
    7778                Pattern p = Pattern.compile(prototypeString);
    7879                Matcher m = p.matcher(testString);
    79                 return m.find();
     80                return REGEX.equals(this) ? m.find() : !m.find();
    8081            case ONE_OF:
    8182                String[] parts = testString.split(";");
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r6248 r6455  
    368368            <EQUAL> <TILDE> { op=Condition.Op.REGEX; } s() val=regex()
    369369        |
     370        LOOKAHEAD(2)
     371            <EXCLAMATION> <TILDE> { op=Condition.Op.NREGEX; } s() val=regex()
     372        |
    370373            (
    371374                    <EXCLAMATION> <EQUAL> { op=Condition.Op.NEQ; }
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.groovy

    r4069 r6455  
    1212    ParsingLinkSelectorTest.class,
    1313    KeyConditionTest.class,
     14    MapCSSParserTest.class,
    1415    ChildOrParentSelectorTest
    1516])
Note: See TracChangeset for help on using the changeset viewer.