Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

attempt to clean up regex a little bit

  • Loading branch information...
commit d976801ddd44fee195e7fcc46872481508e1910d 1 parent 0a0f5db
@beerriot beerriot authored
Showing with 6 additions and 9 deletions.
  1. +6 −9 apps/wriaki/priv/mapred/search_map.js
View
15 apps/wriaki/priv/mapred/search_map.js
@@ -38,16 +38,13 @@ function(v, d) {
// 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];
}
Please sign in to comment.
Something went wrong with that request. Please try again.