regular expressions in tag tests

Hi all! I want to use a regular expression in a tag test, and I don't know what type of regular expression syntax is used in mkgmap. There is only one example, and it's not enough. My tags are strings made from floating point numbers, in fixed field length with leading spaces, in common RE syntax they would be '\ *[0-9]+\.00' (optional spaces, followed by a point and two zeroes) I want to pick out those with '000', '500', '00' and '50' before the point (doing contours) - of course a modulo operation on the floating point value would also work, but I haven't found that, either... How would I specify that in mkgmap? (P.S. I don't know Java, so please don't tell me it's in 'standard Java notation' ;-) Kay

On 06/05/2012 02:15 PM, Kay F. Jahnke wrote: Hi
point numbers, in fixed field length with leading spaces, in common RE syntax they would be
'\ *[0-9]+\.00' (optional spaces, followed by a point and two zeroes)
That will work in java regular expressions too, although I don't think you need the first '\' character.
I want to pick out those with '000', '500', '00' and '50' before the point (doing contours) - of course a modulo operation on the floating point value would also work, but I haven't found that, either...
How would I specify that in mkgmap? (P.S. I don't know Java, so please don't tell me it's in 'standard Java notation' ;-)
I'm not clear exactly what you are trying to match, but if you are familiar with other regular expression languages the one in java is very similar to the one in Perl 5 and other modern languages. See a summary of what it is supported and the differences to Perl 5 at: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html If you are not very familiar with regular expressions in any language then if you reply with a few examples of what you want to match I can probably help out. ..Steve

Am 05.06.2012 16:25, schrieb Steve Ratcliffe:
If you are not very familiar with regular expressions in any language then if you reply with a few examples of what you want to match I can probably help out.
Thank you for your help and prompt reply! Quite familiar, actually - now I managed to work it out. I think mkgmap strips trailing and heading ws from the field content. I stumbled over some of my data having more than two postcomma zeroes (only saw that later, I have a good 1000 files). After some fiddling about I concluded that the whole field content has to be consumed by the RE for a match to occur. So eventually I ended up with this segment in my lines file which now seems to do the job: # only major lines receive a name. Note the conversion to feet. ENT_LIN=2.08.01 & ( QUOTA ~ '.*[05]00\.0+' ) { name '${QUOTA|conv:m=>ft}' } [0x22 level 2] ENT_LIN=2.08.01 & ( QUOTA ~ '.*[05]0\.0+' ) { name '${QUOTA|conv:m=>ft}' } [0x21 level 1] # any remaining contours will be rendered as minor, without name ENT_LIN=2.08.01 [0x20 level 0] the escaped points work as expected. I noticed the example in the wiki was using '\d', so apparently there's shortcuts available (I assume \d is digits - any others?) One more thing: I tried to match a RE at the top level and failed. Is there a workaround to achieve the same thing? My classification is mainly by codes like the ENT_LIN above, and they come in sections. So it would be nice if I could match '2\.08\.??' at the top level. Kay

Hi
Quite familiar, actually - now I managed to work it out. I think mkgmap strips trailing and heading ws from the field content. I stumbled over
I'm pretty sure that it doesn't do that normally.
later, I have a good 1000 files). After some fiddling about I concluded that the whole field content has to be consumed by the RE for a match to
That is right; the regex has to match the whole field.
One more thing: I tried to match a RE at the top level and failed. Is
would be nice if I could match '2\.08\.??' at the top level.
Ha! I've just thought that you can do: ENT_LIN=* & ENT_LIN ~ '2\.08\...' But that means that the code could do this automatically and remove the restriction altogether! ..Steve
participants (3)
-
Kay F. Jahnke
-
Kay F. Jahnke
-
Steve Ratcliffe