[OSM-dev] Split osm line with perl
Anthony
osm at inbox.org
Sun Nov 29 16:47:15 GMT 2009
On Sun, Nov 29, 2009 at 6:41 AM, Lennard <ldp at xs4all.nl> wrote:
> $str =~ /k="([^"]*)" v="([^"]*)"/;
If you don't care about order or number of spaces or anything like
that, a simple "if ($line=~/^ <tag k="(.*)" v="(.*)" />$/)" will
do. The code I gave was actually for parsing "changeset" and "node"
tags, which weren't as uniformly formatted as the "tag" tags, so my
attempts at parsing them using regular expressions got way too
complicated (it might be possible with backreferences and such, but
split worked a lot better).
More information about the dev
mailing list