freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "buddie.wei (Jira)" <j...@apache.org>
Subject [jira] [Created] (FREEMARKER-126) regularExpression cannot use Java pattern as described in the document
Date Fri, 20 Dec 2019 08:33:00 GMT
buddie.wei created FREEMARKER-126:
-------------------------------------

             Summary: regularExpression cannot use Java pattern as described in the document
                 Key: FREEMARKER-126
                 URL: https://issues.apache.org/jira/browse/FREEMARKER-126
             Project: Apache Freemarker
          Issue Type: Bug
          Components: documentation
    Affects Versions: 2.3.26-incubating
            Reporter: buddie.wei


[https://freemarker.apache.org/docs/gloss.html#gloss.regularExpression]

 "FreeMarker uses the variation of regular expressions described at: [http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html]"

 

But in fact, it is not effect if i use java pattern.

For example, i want to remove the domain of a url, like "http://www.abc.com/de/fg" or "https://192.168.1.1:8080/de/fg".

The result i expect is "/de/fg".

In java,

 
{code:java}
url.replaceFirst("http[s]?://[\\w\\.:\\d]*", "");
{code}
{color:#172b4d}The code above can realize my intention.{color}

{color:#172b4d}In freemark,{color}
{code:java}
${url.loginAction?replace('http[s]?://[\\w\\.:\\d]*','','i')}
{code}
{color:#172b4d}It will return the origin url, like "http://www.abc.com/de/fg", not my expect.{color}

 

{color:#172b4d}what can i do?{color}

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message