[Solved] REGEX with two capturing groups
You can use this regex: <result1>(.*?)<result1>(?:(?:.(?!<result1>))*?<result>(.*?)<result>)? Can get your text in group #1 and group #2 (if exists). This regex will give: MATCH 1 1. `A1` 2. `B1` MATCH 2 1. `A2` MATCH 3 1. `A3` 2. `B3` RegEx Demo solved REGEX with two capturing groups