In regular expression (?=…) is a positive lookahead. It checks if the pattern is matched at the current position, but does not include it in the matched result.
Let’s understand this with an example

A list of email addresses are given below and I want to fetch only the usernames of those who have email service provider gmail.
test@gmail.com
hello@yahoo.com
mp34@gmail.com
test1@hotmail.com
my64@gmail.com

Regex will be :

^(.*)(?=@gmail)

Explanation of the regex :
^ : Represents starting of the string.
( : Represents starting of capturing group.
.* : ‘.’ represents any single character and * matches zero or more occurrences of the character.
) : Represents ending of capturing group.
(?= : Represents the starting of positive lookahead
@gmail : This the pattern to match
) : Represents ending of the positive lookahead

This regex pattern will match all those substring after which @gmail occurred but @gmail will not be included to the matched result.
Matched Output (Matched portions are highlighted) :
test@gmail.com
hello@yahoo.com
mp34@gmail.com
test1@hotmail.com
my64@gmail.com

Demo link: https://regex101.com/r/IMsDND/1