Delete Line with e-mail [closed]

-4

There is a form in PHP, which companies use to post vacancies.

Sometimes they put something inside the textarea like:

Send a vacancy to [email protected]

I'd like to VIA PHP, delete all the lines (just the line, in full) that have kept up an email. Here's the example below:

  

Mason Vacancy

     

Salary: XXX

     

City: XXXX

     

Send e-mail with a resume to [email protected]

     

Task: XXXXXXXXXXXXXXXXXX

Should stay:

  

Mason Vacancy

     

Salary: XXX

     

City: XXXX

     

Task: XXXXXXXXXXXXXXXXXX

Remembering that this is not always going to be Send resume to [email protected]. Sometimes they write different, like send data to, send an email with if data. In the end.

    
asked by anonymous 28.03.2016 / 15:51

3 answers

1

Explode the text area in different lines. Scroll through the resulting array by printing only lines that do not have email

$linhas = explode("\n", $textarea);
foreach ($linhas as $linha) {
    // teste básico para presença de email
    if (!preg_match('/[a-z0-9]+@[-a-z0-0]+\.[a-z]+/', $linha)) {
        echo $linha;
    }
}
    
28.03.2016 / 15:58
1

The question is very poorly worded, so you have received so many negatives, I hope you edit it so people will come back to you positively. But from what I understand, you want to filter the email from the textarea field, to do this, there are two ways you can block typing email using javascript:

<script>
    function removerEmail(input)
    {
       input.value = input.value.replace(/(.*)[a-z0-9\.\_\-]+@[a-z0-9\.\_\-]+\.[a-z]+(.*)/gi,'');
    }
</script>

Html:

<textarea onkeyup="removerEmail(this)" onkeypress="removerEmail(this)">
</textarea>

See this example.

And in PHP using a filter for the line that contains the email:

function filterEmail($text)
{
   return preg_replace('/(.*)[a-z0-9\.\_\-]+@[a-z0-9\.\_\-]+\.[a-z]+(.*)/i','', $text);
}
    
28.03.2016 / 16:16
0

I'm not sure where to use it, but when I need to inhibit the user from writing, posting, sending or whatever I know with his email, I use a preg_replace with specs like below. and then the typed e-mail is replaced by [E-MAIL CAN NOT BE DISPLAYED]

$text = preg_replace('/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/','[O E-MAIL NAO PODE SER EXIBIDO]', $text);
    
01.04.2016 / 19:37