Skip to content

Instantly share code, notes, and snippets.

@neilgupta
Created December 4, 2011 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgupta/1429749 to your computer and use it in GitHub Desktop.
Save neilgupta/1429749 to your computer and use it in GitHub Desktop.
Implement substr using regex in javascript... This gist is equivalent to str = str.substr(0,87)+"...";
str = str.replace(/^([\s\S]{0,87})[\s\S]*$/, "$1...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment