Raw Input
Given a line consists of several e-mail addresses separated by spaces, for example:
john@a.com mary@b.com kelly@c.org joe@b.com bruce@e.edu monica@b.comma
Desired Output
What we want is user names of those e-mail addresses destined to @b.com, be aware that 'monica@b.comma' must be filtered out:
 mary joe
Script and Comments
Script1 [perl]
[ 1] s/[^ @]+\@(?!b\.com(?=$| ))[^ ]+//g
[ 2] s/\@b\.com//g
Script2 [sed]
[ 1] s/@b\.com/@/g
[ 2] s/[^ @]*@[^ ][^ ]*//g
[ 3] s/@//g
Comments
  1. If an e-mail address whose host part is exactly 'b.com', Step [1] will remove its host part completely. For example, 'joe@b.com' will be changed to 'joe@', 'monica@b.comma' will be changed to 'monica@ma'.
  2. Step [2] will remove any e-mail address whose host part is NOT empty.
  3. Step [3] is used to remove the '@' following any user name.