rx-atomic-p

rx-atomic-p is a compiled Lisp function in `rx.el'.

(rx-atomic-p R &optional LAX)

Return non-nil if regexp string R is atomic.
An atomic regexp R is one such that a suffix operator
appended to R will apply to all of R. For example, "a"
"[abc]" and "\(ab\|ab*c\)" are atomic and "ab",
"[ab]c", and "ab\|ab*c" are not atomic.

This function may return false negatives, but it will not
return false positives. It is nevertheless useful in
situations where an efficiency shortcut can be taken only if a
regexp is atomic. The function can be improved to detect
more cases of atomic regexps. Presently, this function
detects the following categories of atomic regexp;

a group or shy group: \(...\)
a character class: [...]
a single character: a

On the other hand, false negatives will be returned for
regexps that are atomic but end in operators, such as
"a+". I think these are rare. Probably such cases could
be detected without much effort. A guarantee of no false
negatives would require a theoretic specification of the set
of all atomic regexps.