Select
Enclose all selections in parentheses, separating the adjacent selections by |. But with parentheses there is a side effect that the associated match is cached and available at this time?: Put the first option to eliminate this side effect.
Where?: one of the non-capturing elements, and two non-capturing elements are? = and?!, these two also have more meanings, the former is forward pre-check, in any beginning to match the position of the regular expression pattern within the parentheses to match the search string, the latter is a negative pre-check, Matches the search string at any start where the regular expression pattern does not match.
Back to reference
Adding parentheses around a regular expression pattern or part of a pattern causes the related match to be stored in a temporary buffer, and each captured sub-match is stored according to what is encountered in the regular expression pattern from left to right. The buffer number for the storage sub-match starts at 1 and continues numbering up to 99 sub-expressions. Each buffer can be accessed using ' \ n ', where n is a single or two-bit decimal number that identifies a particular buffer.
You can use the non-capturing metacharacters '?: ', '? = ', or '?! ' to ignore the save of the related match.
Operator precedence for various operators
The operations of the same priority are left-to-right, and the operations of different priorities are higher and lower than before. The precedence of the various operators is from high to low as follows:
Operator description
\ escape Character
(), (?:), (? =), [] parentheses and square brackets
*, +,?, {n}, {n,}, {n,m} qualifier
^, $, \anymetacharacter position and order
| "or" action
Some examples
Regular Expression Description
/\b ([a-z]+) \1\b/gi where a word appears consecutively
/(\w+): \/\/([^/:]+) (: \d*)? ([^#]*)/resolves a URL to a protocol, domain, port, and relative path
/^ (?: chapter| section) [Location of the 1-9][0-9]{0,1}$/positioning chapter
/[-a-z]/A to Z a total of 26 letters plus one-number.
/ter\b/can match chapter, not terminal
/\bapt/ can match Windows95 or Windows98 or WindowsNT, and when a match is found, start the next time from behind Windows