Index: utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java
===================================================================
--- utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java	(revision 27440)
+++ utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java	(working copy)
@@ -147,7 +147,7 @@
      * @param initWays ways to check intersections
      * @param newWays set to place the ways we found
      */
-    static int addWaysIntersectingWays(Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays) {
+    public static int addWaysIntersectingWays(Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays) {
         int count=0;
         for (Way w : initWays){
             count+=addWaysIntersectingWay(allWays, w, newWays);
@@ -171,7 +171,7 @@
         return newNodes.size()-s;
     }
 
-    static void addWaysIntersectingWaysRecursively
+    public static void addWaysIntersectingWaysRecursively
             (Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays)
     {
             Set<Way> foundWays = new HashSet<Way>();
@@ -457,5 +457,36 @@
        // System.out.printf("Intersected intercount %d %s\n",interCount, point.toString());
         if (interCount%2 == 1) return 1; else return 0;
     }
+    
+    public static Collection<OsmPrimitive> selectAllInside(Collection<OsmPrimitive> selected, DataSet dataset) {
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(selected, Way.class);
+        Set<Relation> selectedRels = OsmPrimitive.getFilteredSet(selected, Relation.class);
 
+        for (Relation r: selectedRels) {
+            if (!r.isMultipolygon()) selectedRels.remove(r);
+        }
+
+        Set<Way> newWays = new HashSet<Way>();
+        Set<Node> newNodes = new HashSet<Node>();
+        // select ways attached to already selected ways
+        if (!selectedWays.isEmpty()) {
+            for (Way w: selectedWays) {
+                addAllInsideWay(dataset,w,newWays,newNodes);
+            }
+        }
+        if (!selectedRels.isEmpty()) {
+            for (Relation r: selectedRels) {
+                addAllInsideMultipolygon(dataset,r,newWays,newNodes);
+            }
+        }
+        
+        Set<OsmPrimitive> insideSelection = new HashSet<OsmPrimitive>();
+        if (!newWays.isEmpty() || !newNodes.isEmpty()) {
+            insideSelection.addAll(newWays);
+            insideSelection.addAll(newNodes);
+        }
+        return insideSelection;
+    }
+
+
 }
Index: utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java
===================================================================
--- utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java	(revision 27440)
+++ utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java	(working copy)
@@ -14,10 +14,7 @@
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Relation;
-import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.*;
 import org.openstreetmap.josm.tools.Shortcut;
 
 /**
@@ -31,32 +28,14 @@
                 KeyEvent.VK_I, Shortcut.GROUP_EDIT ,KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK), true);
         putValue("help", ht("/Action/SelectAllInside"));
     }
-
+    
+    @Override
     public void actionPerformed(ActionEvent e) {
         long t=System.currentTimeMillis();
-        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
-        Set<Relation> selectedRels = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Relation.class);
-
-        for (Relation r: selectedRels) {
-            if (!r.isMultipolygon()) selectedRels.remove(r);
-        }
-
-        Set<Way> newWays = new HashSet<Way>();
-        Set<Node> newNodes = new HashSet<Node>();
-        // select ways attached to already selected ways
-        if (!selectedWays.isEmpty()) {
-            for (Way w: selectedWays) {
-                NodeWayUtils.addAllInsideWay(getCurrentDataSet(),w,newWays,newNodes);
-            }
-        }
-        if (!selectedRels.isEmpty()) {
-            for (Relation r: selectedRels) {
-                NodeWayUtils.addAllInsideMultipolygon(getCurrentDataSet(),r,newWays,newNodes);
-            }
-        }
-        if (!newWays.isEmpty() || !newNodes.isEmpty()) {
-            getCurrentDataSet().addSelected(newWays);
-            getCurrentDataSet().addSelected(newNodes);
+        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(getCurrentDataSet().getSelected(), getCurrentDataSet());
+        
+        if (!insideSelected.isEmpty()) {
+            getCurrentDataSet().addSelected(insideSelected);
         } else{
         JOptionPane.showMessageDialog(Main.parent,
                tr("Nothing found. Please select some closed ways or multipolygons to find all primitives inside them!"),
Index: utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
===================================================================
--- utilsplugin2/src/utilsplugin2/UtilsPlugin2.java	(revision 27440)
+++ utilsplugin2/src/utilsplugin2/UtilsPlugin2.java	(working copy)
@@ -1,18 +1,30 @@
 // License: GPL v2 or later. See LICENSE file for details.
 package utilsplugin2;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
 import utilsplugin2.customurl.ChooseURLAction;
 import utilsplugin2.customurl.OpenPageAction;
 import utilsplugin2.customurl.UtilsPluginPreferences;
 
 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
 import java.awt.event.KeyEvent;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import utilsplugin2.selection.*;
 import utilsplugin2.dumbutils.*;
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.search.PushbackTokenizer;
+import org.openstreetmap.josm.actions.search.SearchCompiler;
+import org.openstreetmap.josm.actions.search.SearchCompiler.*;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.plugins.Plugin;
@@ -87,7 +99,8 @@
         
         selectURL = MainMenu.add(toolsMenu, new ChooseURLAction());
         
-
+        // register search operators
+        SearchCompiler.addMatchFactory(new UtilsUnaryMatchFactory());
     }
 
     @Override
@@ -124,5 +137,100 @@
     public PreferenceSetting getPreferenceSetting() {
         return new UtilsPluginPreferences();
     }
+    
+    public static class UtilsUnaryMatchFactory implements UnaryMatchFactory {
+        private static Collection<String> keywords = Arrays.asList("inside",
+                "intersecting", "allintersecting");
+        
+        @Override
+        public UnaryMatch get(String keyword, Match matchOperand, PushbackTokenizer tokenizer) throws ParseError {
+            if ("inside".equals(keyword))
+                return new InsideMatch(matchOperand);
+            else if ("intersecting".equals(keyword))
+                return new IntersectingMatch(matchOperand, false);
+            else if ("allintersecting".equals(keyword))
+                return new IntersectingMatch(matchOperand, true);
+            return null;
+        }
 
+        @Override
+        public Collection<String> getKeywords() {
+            return keywords;
+        }
+    }
+
+    /**
+     * Matches all objects contained within the match expression.
+     */
+    public static class InsideMatch extends UnaryMatch {
+        private Collection<OsmPrimitive> inside = null;
+        
+        public InsideMatch(Match match) {
+            super(match);
+            init();
+        }
+        
+        /**
+         * Find all objects inside areas which match the expression
+         */
+        private void init() {
+            Collection<OsmPrimitive> matchedAreas = new HashSet<OsmPrimitive>();
+
+            // find all ways that match the expression
+            Collection<Way> ways = Main.main.getCurrentDataSet().getWays();
+            for (Way way : ways) {
+                if (match.match(way))
+                    matchedAreas.add(way);
+            }
+            
+            // find all relations that match the expression
+            Collection<Relation> rels = Main.main.getCurrentDataSet().getRelations();
+            for (Relation rel : rels) {
+                if (match.match(rel))
+                    matchedAreas.add(rel);
+            }
+            
+            inside = NodeWayUtils.selectAllInside(matchedAreas, Main.main.getCurrentDataSet());
+        }
+
+        @Override
+        public boolean match(OsmPrimitive osm) {
+            return inside.contains(osm);
+        }
+    }
+    
+    public static class IntersectingMatch extends UnaryMatch {
+        private Collection<Way> intersecting = null;
+        
+        public IntersectingMatch(Match match, boolean all) {
+            super(match);
+            init(all);
+        }   
+        
+        /**
+         * Find (all) ways intersecting ways which match the expression.
+         */
+        private void init(boolean all) {
+            Collection<Way> matchedWays = new HashSet<Way>();
+            
+            // find all ways that match the expression
+            Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
+            for (Way way : allWays) {
+                if (match.match(way))
+                    matchedWays.add(way);
+            }
+            
+            Set<Way> newWays = new HashSet<Way>();
+            if (all)
+                NodeWayUtils.addWaysIntersectingWaysRecursively(allWays, matchedWays, newWays);
+            else
+                NodeWayUtils.addWaysIntersectingWays(allWays, matchedWays, newWays);
+            intersecting = newWays;
+        }
+        
+        @Override
+        public boolean match(OsmPrimitive osm) {
+            return intersecting.contains(osm);
+        }
+    }
 }
