Last active
July 22, 2016 08:33
-
-
Save kentyeh/cbd3e2f3ed8336b9ed0a to your computer and use it in GitHub Desktop.
alert complex message in html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Utilities { | |
private static final Pattern pDquote = Pattern.compile("\""); | |
private static final Pattern pSquote = Pattern.compile("'"); | |
private static final Pattern pBackSlash = Pattern.compile("\\\\"); | |
private static final Pattern pNewline = Pattern.compile("[\n\r]+"); | |
public static String alertInner(String msg) { | |
return msg == null || msg.trim().isEmpty() ? "" : pNewline.matcher( | |
pSquote.matcher(pDquote.matcher(pBackSlash.matcher(msg).replaceAll("\\\\\\\\")).replaceAll(""")).replaceAll("\\\\'")).replaceAll("\\\\r\\\\n"); | |
} | |
public static String alertInFunc(String msg) { | |
return msg == null || msg.trim().isEmpty() ? "" : pNewline.matcher( | |
pSquote.matcher(pDquote.matcher(pBackSlash.matcher(msg).replaceAll("\\\\\\\\")).replaceAll("\\\\\"")).replaceAll("\\\\'")).replaceAll("\\\\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment