Learn Java Programming - Regex Non-Capturing Groups Tutorial

preview_player
Показать описание
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 non-capturing groups, some common uses are: faster search results, inline modifiers (or embedded flag expressions), and excluding patterns from the .group(...) method results. At this point I would like to take a moment to make you aware that the ? metacharacter is just about the most versatile of all the metacharacters and where it is placed in a regex can make a dramatic difference on search results. Non-capturing groups use the same syntax as capturing groups only you must include a ?: just inside of the opening parenthesis.

Inline Modifiers, aka Embedded Flag Expressions
If you have been watching my tutorial series thus far, then you have seen me demonstrate the case-insensitive inline modifier (?i)...
Рекомендации по теме