Skip to content

Instantly share code, notes, and snippets.

@asevos
Created January 13, 2026 11:52
Show Gist options
  • Select an option

  • Save asevos/12af0e832e7dac14b781833d1800d2c2 to your computer and use it in GitHub Desktop.

Select an option

Save asevos/12af0e832e7dac14b781833d1800d2c2 to your computer and use it in GitHub Desktop.
search = {
pattern = [[(?:\/\/|--(\[\[)?|\*|#\|?|%\{?|;|\{-)[\t ]*(?:(KEYWORDS):)]],
--[[
Regex explanation:
1. (?:...) - non-capture group for comment tokens:
\/\/ - matches // , used in lots of languages
--(\[\[)? - matches -- and --[[ , -- used in SQL, Haskell, Lua,
Ada, AppleScript, VHDL, --[[ used in Lua multiline, also
matches <!-- for HTML, XML, Markdown
\* - matches various formats ( /* /** (* ), lines starting
with * in formatted multiline comments (usually
after /* ), also COBOL
#\|? - matches # and #| - lots of languages comment with # ,
### used in CoffeeScript, #| in Racket and Common
Lisp multiline
%\{? - matches % and %{, % used in MATLAB, Erlang, Prolog,
TeX/LaTeX, also %{ used in MATLAB
; - used in Assembly, Lisp, Clojure, Scheme, INI files
{- - Haskel multiline
2. [\t ]* - 0 or any amount of tabs and spaces
3. (?:(KEYWORDS):) - non-capture group with keywords placeholder ending with :
This regex does not match: Python docstrings ( """ or ''' ), Ruby
multiline ( =begin ), Clojure comment reader macro, Batch files,
Roxygen, Fortran, Visual Basic, VBScript, Basic, PostScript, J, M4
]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment