Use the character class [:alpha:]
E.g. [[:alpha:]]+ to match one-or-more such characters.
C-hig (elisp)Char Classes says:
This matches any letter. For multibyte characters, it matches characters whose Unicode general-category property (*note Character Properties::) indicates they are alphabetic characters.
Whereas you were using:
It seems format-time-string uses the same format as strftime(3), and strptime(3) is the reverse of strftime(3), so I wrote an Emacs dynamic module just for strptime(3), for example,
(strptime "2020-04-01" "%Y-%m-%d")
;; => (0 0 0 1 4 2020 3 nil 0)
The result is (SEC MINUTE HOUR DAY MONTH YEAR DOW DST UTCOFF), you can feed it to encode-time
A combination of regexp-quote and format-spec should help in your case. Especially, format-spec works with format specifiers of the format sequences consisting of one % character and one letter.
(defun my-format-spec-to-regexp (format)
"Convert FORMAT with placeholders %Y, %m, and %d into a regexp."
(format-spec (regexp-quote format)
'((?Y . "...
The problem is that \\3 does not correspond to \\(\\]\\)?
Gives you the following regexp:
From a cursory look all regex matching functions end up using compile_pattern which first checks the built-in regex cache for a previously compiled one, compiling one when needed. The cache is a linked list with a hardcoded size of 20 items. New matches are put in the front of the list, essentially creating a LRU mechanism. See search.c for the details.
For starters the non-greedy quantifiers are ??, +?, and *?, and so you haven't specified any non-greedy matching in that regexp.
I strongly recommend using M-x re-builder to visualise what is going on (it will show each group in a different colour).
Looking at part of your regexp, this:
matches a comma and a space, followed by either 《 ...
Emacs regexps don't have arbitrary zero-width look-around assertions, so if you're hoping for a pattern which in its entirety would only ever match those characters (no matter where it started from, or how many times you searched) then you're out of luck. In Emacs such behaviours are achieved using elisp rather than solely with the regexp engine.
You can, ...
Then use match-data or similar functions, if you want the match.
And put that code inside save-excursion if you don't want to end up moving the cursor.
If you want to include newline chars as whitespace chars then use something like
The vertical bar lets you form an alternation, a regular expression which matches any one of several alternatives. Combined with the parentheses, this one matches either the end of the line, or a tab character, or two space characters. See https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Regexps for details.
In trying to answer your problem, I ran into M-x regex-builder, which may help you as you try to build these regular expressions.
Anyways, you've only defined 4 characters to match:
something that's not a # or space
something that's an :alpha:
an equals sign
This regex will get you most of the way there: [[:alpha:]]* = as it will highlight zero or ...
If I understand correct, just add the other keywords to the list. Something like:
;; change to desired operator regex
'(("package" 0 'my-font-lock-gokeyword-face)
("go" 0 'my-font-lock-gokeyword-face)
("defer" 0 'my-font-lock-gokeyword-face)
("package" 0 'my-font-lock-gokeyword-face)))
I understood you want the ...