Given multiple regular expressions, how reliable is it to group these into a single regex, without knowing their contents ahead of time.
e.g.
(re-search-forward
(concat
"\\("
"\\(" user-regex-1 "\\)"
"\\|"
"\\(" user-regex-2 "\\)"
"\\|"
"\\(" user-regex-3 "\\)"
"\\)"),
nil t 1)
Can this reliable enough to be used as an alternative to doing multiple searches?
Or are there common regular expression features that won't work when grouped in this way.
Said differently, if I write a package that uses this as a way to avoid many searches, will users fine some of their regular expressions fail because they are grouped with other expressions.
From a simple test, this should work, including nested grouping.
(string-match "\\(\\(A\\)\\|\\(B\\|C\\)\\)" "C") ;; --> 0 (#o0, #x0, ?\C-@)
Edit to account for invalid regex causing unexpected behavior, each regex can first be tested before use, see How to check a regular expression is valid without using it for a search?