Skip to content

Instantly share code, notes, and snippets.

@jtai
Created February 8, 2012 21:58
Show Gist options
  • Save jtai/1774304 to your computer and use it in GitHub Desktop.
Save jtai/1774304 to your computer and use it in GitHub Desktop.
Escape lucene special chars
string.replace(/[+\-!(){}\[\]^"~*?:\\]|&&|\bAND\b|\|\||\bOR\b/ig, ' ').replace(/\s+/g, ' ').trim();
trim(preg_replace('/\s+/', ' ', preg_replace('/[+\-!(){}\[\]^"~*?:\\\]|&&|\bAND\b|\|\||\bOR\b/i', ' ', $string)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment