In Full Match you get everything that regex says about, even non-capturing groups. You need to get appropriate Match to get rid of non-capturing groups. The other solution is to use positive lookahead instead of capturing group. Check the regex below. I also removed some unnecessary (IMO) groups.

(?:Bundle\s+Components|Included\s+Components)\s+.*?(?=Bundle)

It results with only one, full, match.

Demo

PS: The sign of new line just before "Bundle" will be captured as well in this solution.

Answer from Egan Wolf on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java string › non-capturing regex groups in java
Non-Capturing Regex Groups in Java | Baeldung
January 8, 2024 - The pattern “[^:]:” matches the protocol — for example, “http://“. The non-capturing group “(?:[.a-z]+/?)” matches the domain name with an optional slash. Since the “+” operator matches one or more occurrences of this pattern, we’ll match the subsequent path segments as well.
🌐
TutorialsPoint
tutorialspoint.com › non-capturing-groups-java-regular-expressions
Non capturing groups Java regular expressions:
February 21, 2020 - A non-capturing group starts with (?: and ends with ). import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CapturingGroups { public static void main( String args[] ) { System.out.println("Enter ...
Discussions

Non-capturing group in java RegEx - Stack Overflow
I have written a code, but it doesn't work correctly. Here you can find my RegEx, what I have as the input and what I expect as the output. I am using a non-capturing group, because I want to read ... More on stackoverflow.com
🌐 stackoverflow.com
Java Regex Non-Capturing Group - Stack Overflow
I am having some trouble getting regex to match a string in Java. Here are the strings I want to match: String Transformation Action and Transformation Action. Basically, if String is present, I wa... More on stackoverflow.com
🌐 stackoverflow.com
Non capturing group java regex - Stack Overflow
I saw this post What is a non-capturing group? What does a question mark followed by a colon (?:) mean? And i figured that the following would work, but it doesn't... I have a String "Game No : More on stackoverflow.com
🌐 stackoverflow.com
April 9, 2017
java - regular expressions: quantifying a non-capturing group - Stack Overflow
See here for some background on what I'm trying to do. In short, I want to match any paths under a /path/foo/, unless the leaf directory (not the leaf file), is script. There's some answers in that More on stackoverflow.com
🌐 stackoverflow.com
🌐
O'Reilly
oreilly.com › library › view › java-9-regular › 9781787288706 › a3908c20-1d49-48e1-916f-4fdfcad0af80.xhtml
Non-capturing groups - Java 9 Regular Expressions [Book]
July 25, 2017 - We can mark a group as a non-capturing group by adding a question mark and a colon right after the opening parenthesis.
Author   Anubhava Srivastava
Published   2017
Pages   158
🌐
Java Mex
javamex.com › tutorials › regular_expressions › non_capturing_groups.shtml
Java regular expressions: using non-capturing groups to organise regular expressions
This example matches either a sequence of digits, or a sequence of digits followed by one of the prefixes -st, -nd, -rd, -th (e.g. 1st, 4th). However, only the first group (the digits) is captured. The second group is non-capturing, introduced by ?: inside the brackets.
🌐
O'Reilly
oreilly.com › library › view › java-9-regular › 9781787288706 › 0408480c-ba70-4cbe-b442-b02e624cc214.xhtml
Advantages of non-capturing groups - Java 9 Regular Expressions [Book]
July 25, 2017 - A non-capturing group lets us use the grouping inside a regular expression without changing the numbers assigned to the back references (explained in the next section).
Author   Anubhava Srivastava
Published   2017
Pages   158
Find elsewhere
🌐
QBasic on Your Computer
chortle.ccsu.edu › finiteautomata › Section09 › sect09_16.html
Non-capturing Groups
matches dollar amounts like $10.43 and USD19.98 and saves the dollar amount in \1 and the cents amount in \2. Now a Java program can refer to the dollar and cents amounts as group 1 and group 2, rather than more obscure numbers. (See chapter 11 for how Java programs can use the values held in backreferences.) Another benefit of non-capturing groups is that matching is performed faster.
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › regex › groups.html
Capturing Groups (The Java™ Tutorials > Essential Java Classes > Regular Expressions)
There is also a special group, group 0, which always represents the entire expression. This group is not included in the total reported by groupCount. Groups beginning with (? are pure, non-capturing groups that do not capture text and do not count towards the group total.
🌐
YouTube
youtube.com › watch
Learn Java Programming - Regex Non-Capturing Groups Tutorial - YouTube
A non-capturing group allows you to group a pattern (token) without the regex engine automatically assigning a group number. There are many reasons for using...
Published   February 27, 2016
🌐
CodingTechRoom
codingtechroom.com › tutorial › java-java-regex-non-capturing-groups
Understanding Non-Capturing Groups in Java Regex - CodingTechRoom
Solution: Use `(?:...)` for grouping instead of `(...)` to reduce overhead when you don't need the captured text. Mistake: Overlooking performance in complex regex patterns. Solution: Refactor complex patterns to utilize non-capturing groups where capturing is not needed, thus enhancing performance.
🌐
Reddit
reddit.com › r/regex › can someone explain what are non-capture groups?
r/regex on Reddit: Can someone explain what are non-capture groups?
February 8, 2021 -

Hi everyone!

I'm struggling to understand what are non-capturing groups.

My take and if I understood correctly:

  • when you group, you're applying precedence in terms of evaluation, like normal parenthesis would work in a math expression.

  • a normal group it creates some sort of indexing that the regex engine can use for other checks later on if it has advanced stuff like tagging or recursion.

  • when you use ?: - non-capturing group - you're also grouping as well but it doesn't do any indexing.

Is this correct?

Would there any difference between simple stuff like (^$)|(^(No|Yes)$) to (?:^$)|(?:^(?:No|Yes)$) ?

Thank you in advance.

🌐
Stack Overflow
stackoverflow.com › questions › 39495166 › regex-non-capturing-and-capturing-groups-and-unexplained-consumption
java - regex non-capturing and capturing groups and unexplained consumption - Stack Overflow
I can't follow why these two expressions are different: ^(\d+)(?:\.(\d+))?(?:\.(\d+))?$ applied to 1.0.3 group 1 =>1 group 2 =>0 group 3 =>3 which is expected. but if I try to generalize ...