Replace 2 spaces with tabs
- Find:
^([\t]*)[ ]{2}
- Replace:
$1\t
Markdown RegEx Snippets
Increase Heading Indent Level
- Find:
^#
- Replace
##
Replace markdown link with a
tag, noopener newtab
- 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]*
JS / TS Source Code
Match Imports
Matches top of file imports (RegExr Demo):
/^import\s+.+from.+;?$|import\s+\{[^\}]+\}.+from.+;?$|^import\s["'].+["'].*;?$/gim