Changeset 8482 in josm for trunk


Ignore:
Timestamp:
2015-06-10T21:00:48+02:00 (9 years ago)
Author:
simon04
Message:

Correctly parse tab-separated tags

… by using non-greedy regular expression for prefix to ignore

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r8470 r8482  
    203203        // Format
    204204        // tag1\tval1\ntag2\tval2\n
    205         tags = readTagsByRegexp(buf, "[\\r\\n]+", ".*([a-zA-Z0-9:_]+).*\\t(.*?)", false);
     205        tags = readTagsByRegexp(buf, "[\\r\\n]+", ".*?([a-zA-Z0-9:_]+).*\\t(.*?)", false);
    206206                // try "tag\tvalue\n" format
    207207        if (tags!=null) return tags;
  • trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

    r7937 r8482  
    9595
    9696    }
     97
     98    @Test
     99    public void testTab() throws Exception {
     100        Assert.assertEquals(TextTagParser.readTagsFromText("shop\tjewelry"), Collections.singletonMap("shop", "jewelry"));
     101        Assert.assertEquals(TextTagParser.readTagsFromText("!shop\tjewelry"), Collections.singletonMap("shop", "jewelry"));
     102        Assert.assertEquals(TextTagParser.readTagsFromText("!!!shop\tjewelry"), Collections.singletonMap("shop", "jewelry"));
     103        Assert.assertEquals(TextTagParser.readTagsFromText("shop\t\t\tjewelry"), Collections.singletonMap("shop", "jewelry"));
     104    }
    97105}
Note: See TracChangeset for help on using the changeset viewer.