I'd like to match either word start or subword start in a simple way.
So I went with this regex: "\\(\\b\\sw\\)\\|\\(?:[^A-Z]\\([A-Z]\\)\\)"
.
Note that I want to skip [^A-Z]
and only get the bounds for [A-Z]
, otherwise it would be simple.
What I expected: since there are two capturing groups, tied with an \\|
, (match-string 1) should give me what I want.
What I got: if a word start matches it's in (match-string 1)
, and if a subword start matches it's in (match-string 2)
. That seems pretty useless with no chance to collect the matches in a generic way. How could I rebuild the regex to have both cases in (match-string 1)
?