/* package whatever; // don't place package name! */

import java.util.*;
import java.util.regex.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{

 Pattern p = Pattern.compile("@([^@]{3})@");
 Matcher m = p.matcher("@bla@This is a @red@line @bla@of text");
 Map<String,String> replacement = new HashMap<>();
 replacement.put("bla", "hello,");
 replacement.put("red", "world!");
 StringBuffer sb = new StringBuffer();
 while (m.find()) {
     m.appendReplacement(sb, replacement.get(m.group(1)));
 }
 m.appendTail(sb);
 System.out.println(sb.toString());
 

	}
}