Anonymous avatar Anonymous committed 2b12420

attempt to clean up regex a little bit

Comments (0)

Files changed (1)

apps/wriaki/priv/mapred/search_map.js

 
             // regexp is basically "match START words, then grab everything
             // until WORDS-END words from the end"
+            var w = "[a-z0-9\u80-\uff]"; // word character
+            var n = "[^a-z0-9\u80-\uff]"; // non-word character
+            var skip = "(?:"+w+"{3,}"+n+"+(?:(?:"+w+"|"+w+w+")"+n+"+)*)"
             var match = (new RegExp(
-                "(?:[a-z0-9\u80-\uff]{3,}[^a-z0-9\u80-\uff]+"+
-                    "(?:(?:[a-z0-9\u80-\uff]|[a-z0-9\u80-\uff][a-z0-9\u80-\uff])"+
-                     "[^a-z0-9\u80-\uff]+)*"+
-                    "){"+s+"}"+
-                "(.*)[^a-z0-9\u80-\uff]"+
-                "(?:[a-z0-9\u80-\uff]{3,}[^a-z0-9\u80-\uff]+"+
-                    "(?:(?:[a-z0-9\u80-\uff]|[a-z0-9\u80-\uff][a-z0-9\u80-\uff])"+
-                     "[^a-z0-9\u80-\uff]+)*"+
-                    "){"+(words-e)+"}"))
+                skip+"{"+s+"}"+
+                "(.*)"+n+"*"+
+                skip+"{"+(words-e)+"}"))
                 .exec(text);
             result.ranges[i] = match[1];
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.