7.25. Regex Look Ahead/Behind
7.25.1. Syntax
(?=)- Lookahead(?<=)- Lookbehind(?!foo)- Negative Lookahead(?<!foo)- Negative Lookbehind\K- Stop Look Behind
7.25.2. Example
(?=foo)- asserts that what immediately follows the current position in the string isfoo(?<=foo)- asserts that what immediately precedes the current position in the string isfoo(?!foo)- Asserts that what immediately follows the current position in the string is not foo(?<!foo)- Asserts that what immediately precedes the current position in the string is not foo^\s+sh '\K.+(?=')- if line starts withshat any indentation, then take the content of whats inside of apostrophesd(?=r)- matches adonly if is followed byr, butrwill not be part of the overall regex match(?<=r)d- matches adonly if is preceded by anr, butrwill not be part of the overall regex match