Delete what after @ in the email?

Say I have an email: some_email@yahoo.com .

Firstly, I want to delete everything after @ .

And the last one, delete something inside what remains of the previous action, which corresponds to special characters allowed in the format of the email address (something like "_", "." Or other special characters allowed) and the first letter in the camel hump a word or words if this is the case.

Is it possible and how to do this?

+4
source share
3 answers
function Parse($text) { list($text) = explode('@', $text); $text = preg_replace('/[^a-z0-9]/i', ' ', $text); $text = ucwords($text); return $text; } 

For your input some_email@yahoo.com , it displays "Some Email"

Live action http://codepad.org/w0yfRFbo

+3
source

Try it,

 $str= " abc_abc@xyz.com "; $part = explode('@',$str); $left_part = $part[0]; $left_part = preg_replace('/[^a-zA-Z0-9_ -%][().][\/]/s', '', $left_part); echo $left_part; 
+1
source
 function filter($mail){ $exp = explode('@',$mail); $char = array('.','_','-'); $new = str_replace($char, '', $exp[0]); return strtolower($new); } $mail = ' some_email.new@yahoo.com '; echo filter($mail); 
0
source

Source: https://habr.com/ru/post/1395879/


All Articles