Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Created August 12, 2009 15:52
Show Gist options
  • Select an option

  • Save dieseltravis/166584 to your computer and use it in GitHub Desktop.

Select an option

Save dieseltravis/166584 to your computer and use it in GitHub Desktop.
RegEx to match nested list items pasted from Word in IE6, IE7, and Firefox
var nestedListFixer = /(?:<\/li>(?:<\/ol>\s*)+)+(?:<p(?:\sstyle=\"[^\"]+\")?>(?:\s*<span(?:\sstyle=\"[^\"]+\")?>)*(?:(?:&(?:nbsp|\#0*160|x0*A0);)|\s)+(?:<\/span>)*(?:[ivxlcdm]+\.)(?:\s*<span(?:\sstyle=\"[^\"]+\")?>)*(?:(?:&(?:nbsp|\#0*160|x0*A0);)|\s)+(?:<\/span>)*(.*?)(?:<\/span>)*<\/p>\s*)+(?:<ol(?:\sstyle=\"[^\"]+\")?(?:\stype=\"?\w+\"?)?\sstart=\"?\d+\"?>\s*)+/gi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment