-
-
Notifications
You must be signed in to change notification settings - Fork 0
Snippets
24 snippets. Last updated: 2026-08-18
Snippets run on everything you paste. Each one is a list of find and replace rules, one per line, and the patterns are JavaScript regular expressions. Put the name in a # comment at the top:
# Name of the snippet
s/find/replace/flags
s/find/replace/flags
Copy any block below, open Settings → Better Paste → Custom processing, add a snippet with the (+) button, and paste into the rules field. Want to try a rule first? Open the Better Paste playground on regex101. In the examples, ⏎ marks a line break.
- AI citations and references
- AI formatting
- Links and images
- HTML leftovers
- Lists and spacing
- Writing your own
Perplexity cites as it writes, and the numbered markers come along when you copy. This removes them:
# Remove Perplexity citations
# Remove linked citations like [2](https://source)
s|\[\d+\]\(https?://[^)]*\)||g
# Remove plain citations like [1]
s/\[\d+\]//g
Before:
The sky appears blue because of Rayleigh scattering[1][2]. The same
effect turns sunsets red[3](https://example.com/source).
After:
The sky appears blue because of Rayleigh scattering. The same
effect turns sunsets red.
Keep the two rules in this order. A linked citation like [3](https://example.com/source) must be removed as a whole. With only the plain rule, [3] disappears and (https://example.com/source) stays in your note.
Perplexity's markdown export uses scoped footnotes instead, like [^1_2], with a reference list at the end:
# Remove Perplexity export citations
# Remove citations like [^1_2]
s/\[\^\d+_\d+\]//g
# Remove the reference list at the end
s/^\[\^\d+_\d+\]:.*$\n?//gm
Qubits.[^1_2][^1_3] end → Qubits. end
text⏎[^1_3]: https://ex.com⏎tail → text⏎tail
From ckep1's Perplexity chat exporter.
Answers that used web search sometimes leak internal reference tags into the copied text. Some are visible, like :contentReference[oaicite:3]{index=3}, and some are citation runs wrapped in invisible private-use characters:
# Remove ChatGPT reference tags
# Remove visible tags like :contentReference[oaicite:3]{index=3}
s/:{0,2}contentReference\[oaicite:\d+\]\{index=\d+\}//g
# Remove invisible citation runs wrapped in U+E200 and U+E201
s/[ \t]*\u{E200}[^\u{E201}]*\u{E201}//gu
Paris hosted them.:contentReference[oaicite:3]{index=3} → Paris hosted them.
The invisible runs read like citeturn0search3 when something makes them visible. The first pattern comes from fwerner13's normalize-chatgpt plugin; the invisible markers are reported in r/ChatGPT.
Google AI Overviews wrap their citations in an extra pair of brackets, which Obsidian renders as a broken wikilink:
# Unwrap Google AI Overviews citations
s/^\[(\[\d+\]\(.+\))\]$/$1/gm
[[1](https://a.com), [2](https://b.org)] → [1](https://a.com), [2](https://b.org)
From dawni on the Obsidian forum.
Academic text and markdown exports carry footnote markers like [^12]:
# Remove footnote markers like [^12]
s/\[\^\d{1,3}\]//g
disputed.[^12] Later → disputed. Later
From gino_m on the Obsidian forum.
ChatGPT loves bold headings like ## **Overview**. This unwraps them (one bold pair per heading):
# Remove bold from headings
s/^(#{1,6} .*?)(?<!\\)\*\*([^\n]*?)(?<!\\)\*\*/$1$2/gm
## **Overview** → ## Overview
From churnish on the Obsidian forum.
ChatGPT writes math as \( ... \) and \[ ... \], which Obsidian does not render. This converts both:
# Convert ChatGPT math to dollar math
# Block math to $$ ... $$
s/\\\[([\s\S]*?)\\\]/$$$$$1$$$$/g
# Inline math to $ ... $
s/\\\(([\s\S]*?)\\\)/$$$1$$/g
Energy \( E = mc^2 \) and \[x+y\] → Energy $ E = mc^2 $ and $$x+y$$
The pattern comes from aqhours' Latex2MathJax and GoSlowPoke168's Clean AI Paste, two plugins built around exactly this conversion. The stacked dollar signs are on purpose: in a replacement, $$ produces one literal $. Snippets see the whole paste, code blocks included, so a literal \( inside code converts too. Check the result the first time.
LLMs sprinkle --- between sections. This deletes those lines:
# Remove horizontal rule lines
s/^[ \t]*---[ \t]*\n//gm
end.⏎---⏎## Next → end.⏎## Next
Two things to know: --- also fences frontmatter, and a --- directly under a line of text is a heading in Markdown. Both are rare in mid-answer copies, but check the result the first time. The idea comes from Lymnah's Linter rule with the motivation that separators are "frequently inserted by ChatGPT and other LLMs".
This strips decorative emoji, the 🚀 and 🎯 kind that AI answers put in headings:
# Remove emoji
# At the start of a line, with the space after it
s/^[\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}\u{1F3FB}-\u{1F3FF}\u{20E3}\u{FE0F}\u{200D}]+[ \t]*//gmu
# Everywhere else, with the space before it
s/[ \t]*[\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}\u{1F3FB}-\u{1F3FF}\u{20E3}\u{FE0F}\u{200D}]+//gu
## 🚀 Getting started → ## Getting started
Done 🚀. → Done.
Symbols with a text meaning, like ⌘ and →, are kept. Adapted from GoSlowPoke168's Clean AI Paste.
This turns every markdown link into plain text, keeping the label:
# Convert links to plain text
s/(?<!!)\[([^\]]+)\]\([^)]*\)/$1/g
See [the docs](https://ex.com) now → See the docs now
Adapted from stiang's remove-markdown.
Same idea for images, keeping the alt text. Note that this removes the image before Better Paste can save it, so only use it where images are noise:
# Replace images with their alt text
s/!\[([^\]]*)\]\([^)]*\)/$1/g
 → system overview
Also from remove-markdown.
Web copies often contain links with no text at all, like [](#anchor):
# Remove empty links
s/(?<!!)\[\]\([^)]*\)//g
Overview[](#_anchor) of → Overview of
Adapted from ratacat's slurp-ai scraper.
Documentation pages carry invisible self-link headings that survive the HTML conversion:
# Remove anchor-only headings from web clips
s/^#{2,} \[\]\(.+#.+\)$\n+//gm
## [](https://site.com/docs#install)⏎## Install → ## Install
From siralmat in the Apply Patterns examples.
When a link's text is just the address again, this shortens the label to the bare domain and path:
# Shorten link labels that are bare addresses
s|\[(https?://)?(www\.)?(.+?)/?\]\(|[$3](|g
[https://www.example.com/](https://www.example.com/) → [example.com](https://www.example.com/)
Also from siralmat in the Apply Patterns examples.
Pasted GitHub links with fetched titles read like GitHub - owner/repo: description. This restyles them with the repo name in bold:
# Bold the repo name in GitHub links
s|\[(GitHub - ){0,1}([A-Za-z-\d)]+)\/([A-Za-z\d\-_.]+)(: [^\]]+){0,1}\]\(https:\/\/github.com\/([A-Za-z-\d)]+)\/([A-Za-z\d\-_.]+)\/?\)|[$2/**$3**](https://github.com/$2/$3)$4|g
[GitHub - owner/repo: My tool](https://github.com/owner/repo) → [owner/**repo**](https://github.com/owner/repo): My tool
From claremacrae in the Apply Patterns examples.
Some sites leave HTML behind in the converted markdown. Run these in this order: line breaks first, then comments, then remaining tags, then entities.
# Convert br tags to line breaks
s/<br\s*\/?>/\n/gi
one<br/>two → one⏎two
From Polynomial on Stack Overflow.
# Remove HTML comments
s/<!--[\s\S]*?-->//g
Intro<!-- TODO --> paragraph → Intro paragraph
From Mike Samuel on Stack Overflow.
# Remove leftover HTML tags
s|</?[a-z][a-z0-9]*(\s[^>]*)?/?>||gi
Some <span class="x">highlighted</span> text → Some highlighted text
It keeps prose like x < y and autolinks like <https://example.com> intact. A tamer form of nickf's answer on Stack Overflow.
Escaped entities sometimes survive too. One snippet, six rules, and & must stay last or it double-decodes:
# Decode HTML entities
s/ / /g
s/</</g
s/>/>/g
s/"/"/g
s/'/'/g
s/&/&/g
Fish & Chips <est. 1975> → Fish & Chips <est. 1975>
After lodash's unescape.
Text copied from a chat often arrives with runs of blank lines. This folds every run into one:
# Collapse runs of blank lines into one
s/\n(?:[ \t]*\n){2,}/\n\n/g
one⏎⏎⏎⏎two → one⏎⏎two
Want no blank lines at all? Use s/\n(?:[ \t]*\n)+/\n/g instead. Keep in mind that Markdown joins lines without a blank line between them into one paragraph.
# Remove spaces at line ends
s/[ \t]+$//gm
The end. ⏎Next line → The end.⏎Next line
The m flag makes $ match the end of every line instead of the end of the text.
Word and Pandoc exports pad list markers with extra spaces:
# Fix spacing after list markers
s/^(\s*([-*]|\d\.))\s{2,}/$1 /gm
- item one → - item one
From siralmat in the Apply Patterns examples.
Prefer dashes over asterisks for bullets:
# Use dashes for bullets
s/^(\s*)\* /$1- /gm
* first point → - first point
Adapted from keathmilligan's Paste Reformatter examples.
Double spaces between words, without touching indentation:
# Collapse double spaces between words
s/(?<=\S) {2,}(?=\S)/ /g
the quick brown fox → the quick brown fox
Adapted from BalusC's answer on Stack Overflow.
Rules are JavaScript regular expressions, applied to the whole pasted text from top to bottom.
- Flags: g replaces every match, i ignores case, m makes ^ and $ work per line.
- The delimiter after s is your choice.
s|http://|https://|gavoids escaping slashes. - In the replacement, $1 inserts the first captured group, \n a newline, \t a tab.
- Lines starting with # or // are comments.
- The first # comment names the snippet when you import it or paste it into the editor.
Test your rules in the Try it box in settings, or in the Better Paste playground on regex101. It opens with the citation pattern, a Perplexity sample, and the flavor set to JavaScript, which is the engine the plugin uses.
Have a snippet others could use? Open an issue and I will add it here.