How do I create a regular expression to match subword which start with same prefix, for example aaa
, the random word after that has random length.
aaa[randomword1]aaa[randomword2]
If I use pattern
(aaa\w+)*
it match (aaa)
and [randomword1]aaa[randomword2]
. But I want to match groups: aaa
, randomword1
, aaa
, randomword2
.
EDIT: I mean in the string may have multi times aaa
, and I need match all subword aaa_randomword_times_n
.