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
@
.
abc@gmail.com
Simple as mentions above :
$input=hardiksondagar@gmail.com; // now you want to fetch gmail from input user PHP's inbuilt function preg_match('/@([^.]+)/', $input, $output); echo $output[1]; // it'll print "gmail"