(require 's) ;; All we need is `s-matches-p'
(require 'rx)
Your example:
(s-matches-p (concat "\\<" (regexp-opt '("nil" "t") t) "\\>") "nil_finder")
;; t
(s-matches-p (concat "\\<" (regexp-opt '("nil" "t") t) "\\>") "nil")
;; t
Fixed:
(s-matches-p
(concat
(rx symbol-start)
(regexp-opt '("nil" "t") t)
(rx symbol-end))
"nil_finder")
;; nil
(s-matches-p
(concat
(rx symbol-start)
(regexp-opt '("nil" "t") t)
(rx symbol-end))
"nil")
;; t
Better way:
(s-matches-p (rx symbol-start (or "nil" "t") symbol-end) "nil_finder")
;; nnil
(s-matches-p (rx symbol-start (or "nil" "t") symbol-end) "nil")
;; nt