I am attempting to capture all matching groups rather than 1.
Turing > 128 gb Apple iPhone SE (AiSE) 128 gb Apple iPhone SE (AiSE)
I am using the following regex:
\b(\w+)\b(?=.*?\b\1\b)
but it is still开发者_开发知识库 not working. Can someone please help me capture all matching groups rather than 1?
We can try matching on the following regex pattern:
\d+ [a-z]b(?: \S+)*?(?= \d+ [a-z]b\b|$)
Explanation:
\d+
match a memory size[a-z]b
size units (e.g.gb
)(?: \S+)*?
then match any number of following terms until asserting that(?=
\d+ [a-z]b\b
space followed by another memory term follows|
OR$
the end of the string follows
)
Here is a link to a regex demo.
精彩评论