subst function and literal dots in regular expressions

Hi, I am trying to normalise street names by removing any dots. So far I have been unable to get the subst function to do what I want. The problem seems to be getting the dot to be taken literally in the subst parameters. I have tried: a) set newname='${name|subst:. +=> }' b) set newname='${name|subst:. +=> }' c) set newname='${name|subst:[.] +=> }' All of the above seem to have no effect, i.e. newname ends up the same as name. I am thinking of doing it in two stages: firstly replacing ". " (dot followed by space) with a space, and then replacing any other dots with a space so "A.B. Street" ends up as "A B Street". I could also do it by replacing any dots by spaces and then compressing multiple spaces. But in both cases I need subst to match a literal dot. My current style rules look like this: highway=* & name ~ '.*[.].*' {set newname='${name|subst:. +=> }'} newname=* {echo "dots changed from ${name} to ${newname} (1)"; set name='${newname}'} highway=* & name ~ '.*[.].*' {set newname='${name|subst:[.]=> }'} newname=* {echo "dots changed from ${name} to ${newname} (2)"; set name='${newname}'} Can anyone help please? Colin

On 25/05/14 11:14, Colin Smale wrote:
I am trying to normalise street names by removing any dots. So far I have been unable to get the subst function to do what I want. The problem seems to be getting the dot to be taken literally in the subst parameters.
I have tried:
a) set newname='${name|subst:. +=> }'
Originally subst was a straight forward string replacement. So ${name|subst:.=> } would replace each dot with a space. Also because multiple spaces are combined into one elsewhere this actually has the effect you want in this case. Regular expressions were added later and you need to use ~> instead of => to indicate this. So this will work: ${name|subst:\.+~> } It may just be an email formating issue, but in your email there is a space after the '.'; make sure that there isn't one in your style file. ..Steve

Many thanks Steve, it's working now. The problem was the operator needing to be ~> instead of =>. The space after the dot in the pattern was intentional - in my example of "A.B. Street" I did it in two steps, firstly to "A.B Street" and secondly from there to "A B Street". I was doing that because I wanted to avoid double spaces, but now I know that is taken care of later, things are a simpler. Colin On 2014-05-25 12:49, Steve Ratcliffe wrote:
On 25/05/14 11:14, Colin Smale wrote:
I am trying to normalise street names by removing any dots. So far I have been unable to get the subst function to do what I want. The problem seems to be getting the dot to be taken literally in the subst parameters. I have tried: a) set newname='${name|subst:. +=> }'
Originally subst was a straight forward string replacement. So
${name|subst:.=> }
would replace each dot with a space. Also because multiple spaces are combined into one elsewhere this actually has the effect you want in this case.
Regular expressions were added later and you need to use ~> instead of => to indicate this. So this will work:
${name|subst:.+~> }
It may just be an email formating issue, but in your email there is a space after the '.'; make sure that there isn't one in your style file.
..Steve _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev [1]
Links: ------ [1] http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
participants (2)
-
Colin Smale
-
Steve Ratcliffe