Suppose I have the string text\\
, I need to replace \\
with /
. I tried the following expression:
/* str = "text\\" */
<h:outputText value="#{fn:replace(str, '\\', '/')}" />
But I always run into the following exception:
Caused by: java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
^
at java.util.regex.Pattern.error(Pattern.java:1924)
at java.util.regex.Pattern.compile(Pattern.java:1671)
at java.util.regex.Pattern.<init>(Pattern.java:1337)
at java.util.regex.Pattern.compile(Pattern.java:1022)
at java.lang.String.replaceAll(String.java:2210)
at com.sun.faces.facelets.tag.jstl.fn.JstlFunction.replace(JstlFunction.java:222)
I'd be very grateful if you could give me an advice.
UPDATE: Based on the answers below, I found out that the following expression will work:
<h:outputText value="#{fn:replace(str, '\\\\', '/')}" />
Best regards,