I am new to regex in php, I am trying to get the values between @
and .
in a string.
for example if a string contains value abc@gmail.com
$str = 'abc@gmail.com';
preg_match('/@([^.]+)/', $str, $match);
echo $match[1]; // gmail
Breakdown of above:
@
start search from the character @
[^.]+
match 1 or more characters that are not the character .
( )
is to capture that portion in a backreference which in this case would be the index 1$match[1]