public static String escapeTextForExpression(String text) {
		if (text == null)
			return null;
		text = text.replaceAll("\\\\", "\\\\\\\\");
		text = text.replaceAll("\"", "\\\\\"");
		return text;
	}
public static String escapeTextForExpression ( String text ) { if ( text == null ) return null ; text = text . replaceAll ( "\\\\" , "\\\\\\\\" ) ; text = text . replaceAll ( "\"" , "\\\\\"" ) ; return text ; }
When adding a text to an expression, we have to make sure that the String will not
break JasperReports expression syntax.<br>
For example: if the title text is: <b>November "2009" sales</b><br>
The double quotes (") must be escaped to <b>\"</b>, and in java that would be <b>\\\\\"</b><br>

single bars "\" are escaped to "\\"

To understand better, the expression can be tested in iReport expression editor.
@param text
@return