replace all instance of email addresses with “@example.com”

(another question, sorry but stressing for exam).

I have a file I am going to read in from STDIN. It has text and bunch of emails in the text.

"blah blah blah something john@smith.com blah blah james@john.com".

i want to replace all email addresses domain name with "@example.com". So the above becomes

"blah blah blah something john@example.com blah blah james@example.com"

Here is the code i have so far.

#!/usr/bin/perl

while($line = <STDIN>){
  $line =~ s/'@'+'.com'\s/"@example.com"/g;

  print $line;
 }

Answers


$line =~ s/(\S+)@\S+/$1\@example.com/g;

Need Your Help

Entity Framework downgrade to 3.5

entity-framework .net-3.5 .net-4.0

I had a code below, when application target was .NET4.

Android App for Facebook

android facebook

I'm not sure what language android uses but I'm doing some reading on it now.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.