Package com.helger.html.js
Class JSMarshaller
- java.lang.Object
-
- com.helger.html.js.JSMarshaller
-
@Immutable public final class JSMarshaller extends Object
JavaScript String helper- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisJSIdentifier(String s)static StringjavaScriptEscape(String sInput)Turn special characters into escaped characters conforming to JavaScript.static StringjavaScriptEscapeForRegEx(char cInput)static StringjavaScriptEscapeForRegEx(String sInput)Turn special regular expression characters into escaped characters conforming to JavaScript.
Reference: MDN Regular Expressionsstatic StringjavaScriptUnescape(String sInput)Unescape a previously escaped string.
Important: this is not a 100% reversion ofjavaScriptEscape(String)since the escaping method drops any '\r' character and it will therefore not be unescaped!
-
-
-
Method Detail
-
javaScriptEscape
@Nullable public static String javaScriptEscape(@Nullable String sInput)
Turn special characters into escaped characters conforming to JavaScript. Handles complete character set defined in HTML 4.01 recommendation.
Reference: Core JavaScript 1.5 Guide- Parameters:
sInput- the input string- Returns:
- the escaped string
-
javaScriptEscapeForRegEx
@Nullable public static String javaScriptEscapeForRegEx(@Nullable String sInput)
Turn special regular expression characters into escaped characters conforming to JavaScript.
Reference: MDN Regular Expressions- Parameters:
sInput- the input string- Returns:
- the escaped string
-
javaScriptUnescape
@Nullable public static String javaScriptUnescape(@Nullable String sInput)
Unescape a previously escaped string.
Important: this is not a 100% reversion ofjavaScriptEscape(String)since the escaping method drops any '\r' character and it will therefore not be unescaped!- Parameters:
sInput- The string to be unescaped. May benull.- Returns:
- The unescaped string.
- See Also:
javaScriptEscape(String)
-
-