Skip to content

Custom regex scopes

Silico_Biomancer edited this page Sep 4, 2025 · 8 revisions

Examples

Spoken form Regex Notes Example
dotted
"[\w.]+"
Matches dotted expression one.two.three
pair math
"$[^$]*$"      
Matches latex inlined math expression. May fail to match if line has unmatched expressions. $e^{\pi i}=-1$
inside math
"[^$]*"
Matches interior of a latex inlined math expression e^{\pi i}=-1
chain pipe
(?:%>%|%<>%|%T>%||>)
Matches R pipe operators %>%, %<>%, %T>%, |>
inside chain
(?<=(?:%>%|%<>%|%T>%||>)\s*)\S.?\S(?=\s(?:%>%|%<>%|%T>%||>))
Matches content between pipe operators in R chains filter(x > 0)
head chain
(?<=(?:%>%|%<>%|%T>%||>)\s*)\S[^|%\n]*
Matches content from current position until next pipe operator mutate(y = x * 2) %>%
tail chain
\S.?\S?(?=\s(?:%>%|%<>%|%T>%||>))
Matches content from pipe until current position %>% filter(x > 0)

Note

Feel free to add your own examples here.

Clone this wiki locally