Pattern portp = Pattern.compile("\\$\\(([^\\.]+)\\.([^\\.]+)\\)");
Pattern portp = Pattern.compile("\\$\\(([^\\.\\)]+)\\.([^\\.\\)]+)\\)");
	public String matchAndReplace(String value) {		if (value==null || value.indexOf('$')<0) return value;				//DebugSystem.out.println("matchandreplace "+value);				// by definition from ebnfg - \0 is bad character, but occurs in groups		//Pattern macrop = Pattern.compile("$\\(([a-zA-Z0-9_:-]+)\\)");		//Pattern portp = Pattern.compile("$\\(([a-zA-Z0-9_:-]+)\\.([a-zA-Z0-9_:-]+)\\)");		Pattern macrop = Pattern.compile("\\$\\(([^\\.\\$]+)\\)");		//Pattern portp = Pattern.compile("\\$\\(([^\\.\\$]+)\\.([^\\.\\$]+)\\)");		Pattern portp = Pattern.compile("\\$\\(([^\\.]+)\\.([^\\.]+)\\)");				Matcher port = portp.matcher(value);		StringBuffer result = new StringBuffer();		while (port.find()) {			String portt=port.group(1), portn=port.group(2);			port.appendReplacement(result, findAndResolvePort(portt, portn).replaceAll("\\$","\\\\\\$"));		}		port.appendTail(result);				Matcher macro = macrop.matcher(result.toString());		result=new StringBuffer();		while (macro.find()) {			String macron=macro.group(1);			macro.appendReplacement(result, findAndResolveMacro(macron).replaceAll("\\$","\\\\\\$"));		}		macro.appendTail(result);				return result.toString();	}