How can I test if "(" or ")" is part of name

I have a problem that I cannot escape brackets when trying to find out if they are part of the name... name ~ '.*(' { } is not working of course. However ^ is not able to escape a bracket... name ~ '.*^(' { } Is there any way to find out if there is a () in a name? (the reason for this is that I want to know in Japan if the name is only in Japanese, or in Japanese (English). -- keep on biking and discovering new trails Felix openmtbmap.org & www.velomap.org

Hi Felix, the normal escape character is the backslash \. See also http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html Gerd
Date: Mon, 28 Jul 2014 10:33:25 +0200 From: extremecarver@gmail.com To: mkgmap-dev@lists.mkgmap.org.uk Subject: [mkgmap-dev] How can I test if "(" or ")" is part of name
I have a problem that I cannot escape brackets when trying to find out if they are part of the name...
name ~ '.*(' { } is not working of course. However ^ is not able to escape a bracket... name ~ '.*^(' { }
Is there any way to find out if there is a () in a name? (the reason for this is that I want to know in Japan if the name is only in Japanese, or in Japanese (English).
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Well that's what I thought too... - so I tried many many possibilities. However the strange this is - now that you said it and I tried it again. It only works for ) , not for ( (I first only tried opening parentheses so thought it is not working at all...) name ~ '.*\(' { set name='${name|subst:"(=>"}'; echo "namehasbracket=1" } name ~ '.*\)' { set name='${name|subst:")=>"}'; echo "namehasbracket=2" } second rule is working, first rule not working... Also not working is: '.*\Q(\E' or '.*[(]' On 28.07.2014 11:02, Gerd Petermann wrote:
Hi Felix,
the normal escape character is the backslash \. See also http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Gerd
Date: Mon, 28 Jul 2014 10:33:25 +0200 From: extremecarver@gmail.com To: mkgmap-dev@lists.mkgmap.org.uk Subject: [mkgmap-dev] How can I test if "(" or ")" is part of name
I have a problem that I cannot escape brackets when trying to find out if they are part of the name...
name ~ '.*(' { } is not working of course. However ^ is not able to escape a bracket... name ~ '.*^(' { }
Is there any way to find out if there is a () in a name? (the reason for this is that I want to know in Japan if the name is only in Japanese, or in Japanese (English).
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- keep on biking and discovering new trails Felix openmtbmap.org & www.velomap.org

Hi Felix, okay, sounds like an mkgmap problem then. Try to use the hex format: \xhh The character with hexadecimal value 0xhh Gerd Felix Hartmann-2 wrote
Well that's what I thought too... - so I tried many many possibilities. However the strange this is - now that you said it and I tried it again. It only works for ) , not for ( (I first only tried opening parentheses so thought it is not working at all...)
name ~ '.*\(' { set name='${name|subst:"(=>"}'; echo "namehasbracket=1" } name ~ '.*\)' { set name='${name|subst:")=>"}'; echo "namehasbracket=2" }
second rule is working, first rule not working...
Also not working is: '.*\Q(\E'
or '.*[(]'
On 28.07.2014 11:02, Gerd Petermann wrote:
Hi Felix,
the normal escape character is the backslash \. See also http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Gerd
Date: Mon, 28 Jul 2014 10:33:25 +0200 From:
extremecarver@
To:
mkgmap-dev@.org
Subject: [mkgmap-dev] How can I test if "(" or ")" is part of name
I have a problem that I cannot escape brackets when trying to find out if they are part of the name...
name ~ '.*(' { } is not working of course. However ^ is not able to escape a bracket... name ~ '.*^(' { }
Is there any way to find out if there is a () in a name? (the reason for this is that I want to know in Japan if the name is only in Japanese, or in Japanese (English).
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
-- View this message in context: http://gis.19327.n5.nabble.com/How-can-I-test-if-or-is-part-of-name-tp581287... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Thanks Gerd, well no show - if that is what you meant name ~ '.*\xhh(' ^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.x(Unknown Source) at java.util.regex.Pattern.escape(Unknown Source) at java.util.regex.Pattern.atom(Unknown Source) at java.util.regex.Pattern.sequence(Unknown Source) at java.util.regex.Pattern.expr(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.util.regex.Pattern.<init>(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at uk.me.parabola.mkgmap.osmstyle.eval.RegexOp.setSecond(RegexOp.java:51) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.runOp(ExpressionReader.java:180) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.readConditions(ExpressionReader.java:85) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:115) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.checkCommand(RuleFileReader.java:192) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:109) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.load(RuleFileReader.java:86) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readRules(StyleImpl.java:294) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.<init>(StyleImpl.java:160) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readStyle(StyleImpl.java:554) at uk.me.parabola.mkgmap.reader.osm.RelationStyleHook.init(RelationStyleHook.java:38) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.pluginChain(OsmMapDataSource.java:185) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSource.java:153) at uk.me.parabola.mkgmap.reader.osm.bin.OsmBinMapDataSource.load(OsmBinMapDataSource.java:49) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java:127) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:167) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:63) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:253) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:249) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.util.regex.PatternSyntaxException: Illegal hexadecimal escape sequence near index 4 .*\xhh( On 28.07.2014 11:30, GerdP wrote:
Hi Felix,
okay, sounds like an mkgmap problem then. Try to use the hex format: \xhh The character with hexadecimal value 0xhh
Gerd
Felix Hartmann-2 wrote
Well that's what I thought too... - so I tried many many possibilities. However the strange this is - now that you said it and I tried it again. It only works for ) , not for ( (I first only tried opening parentheses so thought it is not working at all...)
name ~ '.*\(' { set name='${name|subst:"(=>"}'; echo "namehasbracket=1" } name ~ '.*\)' { set name='${name|subst:")=>"}'; echo "namehasbracket=2" }
second rule is working, first rule not working...
Also not working is: '.*\Q(\E'
or '.*[(]'
On 28.07.2014 11:02, Gerd Petermann wrote:
Hi Felix,
the normal escape character is the backslash \. See also http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Gerd
Date: Mon, 28 Jul 2014 10:33:25 +0200 From: extremecarver@ To: mkgmap-dev@.org Subject: [mkgmap-dev] How can I test if "(" or ")" is part of name
I have a problem that I cannot escape brackets when trying to find out if they are part of the name...
name ~ '.*(' { } is not working of course. However ^ is not able to escape a bracket... name ~ '.*^(' { }
Is there any way to find out if there is a () in a name? (the reason for this is that I want to know in Japan if the name is only in Japanese, or in Japanese (English).
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev -- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@.org http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- View this message in context: http://gis.19327.n5.nabble.com/How-can-I-test-if-or-is-part-of-name-tp581287... Sent from the Mkgmap Development mailing list archive at Nabble.com. _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- keep on biking and discovering new trails Felix openmtbmap.org & www.velomap.org

Hi Felix, no, I meant something like name ~ '.*\x28' where 0x28 is the ASCII hex code for (. Gerd Felix Hartmann-2 wrote
Thanks Gerd,
well no show - if that is what you meant name ~ '.*\xhh('
^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.x(Unknown Source) at java.util.regex.Pattern.escape(Unknown Source) at java.util.regex.Pattern.atom(Unknown Source) at java.util.regex.Pattern.sequence(Unknown Source) at java.util.regex.Pattern.expr(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.util.regex.Pattern. <init> (Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at uk.me.parabola.mkgmap.osmstyle.eval.RegexOp.setSecond(RegexOp.java:51) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.runOp(ExpressionReader.java:180) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.readConditions(ExpressionReader.java:85) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:115) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.checkCommand(RuleFileReader.java:192) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.loadFile(RuleFileReader.java:109) at uk.me.parabola.mkgmap.osmstyle.RuleFileReader.load(RuleFileReader.java:86) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readRules(StyleImpl.java:294) at uk.me.parabola.mkgmap.osmstyle.StyleImpl. <init> (StyleImpl.java:160) at uk.me.parabola.mkgmap.osmstyle.StyleImpl.readStyle(StyleImpl.java:554) at uk.me.parabola.mkgmap.reader.osm.RelationStyleHook.init(RelationStyleHook.java:38) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.pluginChain(OsmMapDataSource.java:185) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.setupHandler(OsmMapDataSource.java:153) at uk.me.parabola.mkgmap.reader.osm.bin.OsmBinMapDataSource.load(OsmBinMapDataSource.java:49) at uk.me.parabola.mkgmap.reader.osm.OsmMapDataSource.load(OsmMapDataSource.java:127) at uk.me.parabola.mkgmap.main.MapMaker.loadFromFile(MapMaker.java:167) at uk.me.parabola.mkgmap.main.MapMaker.makeMap(MapMaker.java:63) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:253) at uk.me.parabola.mkgmap.main.Main$1.call(Main.java:249) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.util.regex.PatternSyntaxException: Illegal hexadecimal escape sequence near index 4 .*\xhh(
On 28.07.2014 11:30, GerdP wrote:
Hi Felix,
okay, sounds like an mkgmap problem then. Try to use the hex format: \xhh The character with hexadecimal value 0xhh
Gerd
Felix Hartmann-2 wrote
Well that's what I thought too... - so I tried many many possibilities. However the strange this is - now that you said it and I tried it again. It only works for ) , not for ( (I first only tried opening parentheses so thought it is not working at all...)
name ~ '.*\(' { set name='${name|subst:"(=>"}'; echo "namehasbracket=1" } name ~ '.*\)' { set name='${name|subst:")=>"}'; echo "namehasbracket=2" }
second rule is working, first rule not working...
Also not working is: '.*\Q(\E'
or '.*[(]'
On 28.07.2014 11:02, Gerd Petermann wrote:
Hi Felix,
the normal escape character is the backslash \. See also http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Gerd
Date: Mon, 28 Jul 2014 10:33:25 +0200 From: extremecarver@ To: mkgmap-dev@.org Subject: [mkgmap-dev] How can I test if "(" or ")" is part of name
I have a problem that I cannot escape brackets when trying to find out if they are part of the name...
name ~ '.*(' { } is not working of course. However ^ is not able to escape a bracket... name ~ '.*^(' { }
Is there any way to find out if there is a () in a name? (the reason for this is that I want to know in Japan if the name is only in Japanese, or in Japanese (English).
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev -- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@.org http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- View this message in context: http://gis.19327.n5.nabble.com/How-can-I-test-if-or-is-part-of-name-tp581287... Sent from the Mkgmap Development mailing list archive at Nabble.com. _______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
-- keep on biking and discovering new trails
Felix openmtbmap.org & www.velomap.org
_______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
-- View this message in context: http://gis.19327.n5.nabble.com/How-can-I-test-if-or-is-part-of-name-tp581287... Sent from the Mkgmap Development mailing list archive at Nabble.com.

On 28/07/14 10:15, Felix Hartmann wrote:
name ~ '.*\(' { set name='${name|subst:"(=>"}'; echo "namehasbracket=1" } name ~ '.*\)' { set name='${name|subst:")=>"}'; echo "namehasbracket=2" }
I looked at the code and the way the code currently is, the pattern has to match the whole name. Eg you would need '.*\(.*' and '.*\).*' but the second one would happen to match if the closing bracket was at the end of the string which it probably is in many cases. I found this surprising so I suggest that we change this so that it will match anywhere in the string. That means that you would just need '\(' to match an open parenthesis. But this would not be entirely backward compatible, so it is up to you guys as to whether it is worth doing or not. ..Steve

Ah - thanks for the clarification... I could continue to live with the old behaviour - twould just be nice if it were mentioned in the style manual because it is not that intuitive. If it is changed, that's fine with me too. I just tried - I can also do: name ~ '.*\(.*\).*' { set name='${name|subst:"(=>"}'; set name='${name|subst:")=>"}'; echo "namehasbracket=1" } so that's the easiest (I was looking for closing parentheses only anyhow). Thanks a lot... On 28.07.2014 12:19, Steve Ratcliffe wrote:
On 28/07/14 10:15, Felix Hartmann wrote:
name ~ '.*\(' { set name='${name|subst:"(=>"}'; echo "namehasbracket=1" } name ~ '.*\)' { set name='${name|subst:")=>"}'; echo "namehasbracket=2" }
I looked at the code and the way the code currently is, the pattern has to match the whole name. Eg you would need '.*\(.*' and '.*\).*' but the second one would happen to match if the closing bracket was at the end of the string which it probably is in many cases.
I found this surprising so I suggest that we change this so that it will match anywhere in the string. That means that you would just need '\(' to match an open parenthesis.
But this would not be entirely backward compatible, so it is up to you guys as to whether it is worth doing or not.
..Steve
-- keep on biking and discovering new trails Felix openmtbmap.org & www.velomap.org
participants (4)
-
Felix Hartmann
-
Gerd Petermann
-
GerdP
-
Steve Ratcliffe