Joshua's Docs - Regex Snippets
Light
help

Replace 2 spaces with tabs

  • Find: ^([\t]*)[ ]{2}
  • Replace: $1\t

Markdown RegEx Snippets

  • Find: ([^!]{1})\[([^\[\]]+)\]\(([^)]+)\)
  • Replace: $1<a href="$3" rel="noopener" target="_blank">$2</a>

Find Lists that are missing empty line prefix

Empty lines before lists are required in many non-commonmark implementations of Markdown. This should find them (although it will also flag front-matter)

// https://regexr.com/5fqoh
const pattern = /^.+(?:\r\n|[\r\n]{1})[ \t]*(?:[-*]|\d\.)/gm;
const testStr = `
Paragraph text
 - List item A
 - List item B
 - List item C

Paragraph text
	- List item A
	- List item B
	- List item C
	
Paragraph text
 1. List item A
 2. List item B
 3. List item C
 
23 paragraph text
 - List item A
 - List item B
 
Paragraph text

 - List item A
 - List item B
`;

Remove front-matter block

  • Pattern: ---[\r\n]+(?:.|[\r\n])*---[\r\n]*
Markdown Source Last Updated:
Mon Nov 09 2020 04:24:30 GMT+0000 (Coordinated Universal Time)
Markdown Source Created:
Tue Dec 31 2019 00:15:59 GMT+0000 (Coordinated Universal Time)
© 2020 Joshua Tzucker, Built with Gatsby
Feedback