The main uses are the following three kinds:
1. (...)
Grouping. Group items into a single unit that can is used with *, +, ?, |, and,. Also Remember the characters that is the match this group for use with later references.
2. (?:...)
Grouping only. Group items into a single unit, but does not remember the characters of that match this group.
3.
(? =P) A Positive lookahead assertion. or
(?! P ) A negative lookahead assertion.
String used for testing: URL (skins/default/images/index/default.png)
The red character is the result of the match
The first, which is used for general grouping, remembers strings that match the group, and can later refer to the grouped groupings by \1
Eg: (\/) matching URL (skins/default/images/index/default.png)
(\/) default\1 matching URL (skins/default/images/index/default.png)
The second, for grouping, does not record the string that matches the group
Eg: (?: \ /) Default matching URL (skins/default/images/index/default.png)
The results of the first to second two ways of matching include the result that the packet matches, in the case of "/default" in the "/"
The third, which is used only to determine the location, does not contain the result that the bracket matches.
Eg: (?!) \/) Default matching URL (skins/default/images/index/default.png)
Eg:default (? =\/) matching URL (skins/default/images/index/default.png)