Index: /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/SubstitutionFilter.java
===================================================================
--- /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/SubstitutionFilter.java	(revision 0)
+++ /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/SubstitutionFilter.java	(revision 0)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Toby Speight
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+package uk.me.parabola.mkgmap.osmstyle.actions;
+
+/**
+ * Perform simple string substition on a value.
+ *
+ * @author Toby Speight
+ */
+public class SubstitutionFilter extends ValueFilter {
+    private final String from;
+    private final String to;
+
+    public SubstitutionFilter(String arg) {
+        int i = arg.indexOf("=>");
+        if (i < 0)
+            throw new IllegalArgumentException("'=>' not present");
+        from = arg.substring(0, i);
+        to = arg.substring(i + 2);
+    }
+
+    public String doFilter(String value) {
+        if (value == null) return null;
+        if (from == null || to == null)
+            // can't happen!
+            return value;
+        return value.replace(from, to);
+    }
+}
Index: /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
===================================================================
--- /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java	(revision 1000)
+++ /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java	(working copy)
@@ -27,6 +27,7 @@
  * Build a value that can have tag values substituted in it.
  *
  * @author Steve Ratcliffe
+ * @author Toby Speight
  */
 public class ValueBuilder {
 
@@ -92,20 +93,21 @@
 			switch (state) {
 			case 0:
 				if (c == '$') {
-					if (text.length() > 0) {
-						items.add(new ValueItem(text.toString()));
-						text.setLength(0);
-					}
 					state = 1;
 				} else
 					text.append(c);
 				break;
 			case 1:
 				if (c == '{') {
+					if (text.length() > 0) {
+						items.add(new ValueItem(text.toString()));
+						text.setLength(0);
+					}
 					tagname = new StringBuilder();
 					state = 2;
 				} else {
 					state = 0;
+					text.append('$');
 					text.append(c);
 				}
 				break;
@@ -154,6 +156,10 @@
 			item.addFilter(new DefaultFilter(arg));
 		} else if (cmd.equals("conv")) {
 			item.addFilter(new ConvertFilter(arg));
+		} else if (cmd.equals("subst")) {
+			item.addFilter(new SubstitutionFilter(arg));
+		} else if (cmd.equals("prefix")) {
+			item.addFilter(new PrependFilter(arg));
 		}
 	}
 
Index: /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/PrependFilter.java
===================================================================
--- /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/PrependFilter.java	(revision 0)
+++ /home/tms/maps/mkgmap/trunk/src/uk/me/parabola/mkgmap/osmstyle/actions/PrependFilter.java	(revision 0)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Toby Speight
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+
+package uk.me.parabola.mkgmap.osmstyle.actions;
+
+/**
+ * Prepend a Garmin magic-character to the value.
+ * TODO: symbolic names?
+ *
+ * @author Toby Speight
+ */
+public class PrependFilter extends ValueFilter {
+    private final char prefix;
+
+    public PrependFilter(String s) {
+        // For now, s is a hex constant character number
+        // TODO: that might change!
+        prefix = (char)Integer.parseInt(s, 16);
+    }
+
+    public String doFilter(String value) {
+        return value == null ? null : prefix + value;
+    }
+}
