欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Freemaker Replace函數(shù)的正則表達(dá)式運(yùn)用

 更新時(shí)間:2015年12月17日 14:50:17   作者:jerrylsxu  
這篇文章主要介紹了Freemaker Replace函數(shù)的正則表達(dá)式運(yùn)用 的相關(guān)資料,需要的朋友可以參考下

replace(param1,param2,param3)

param1 正則表達(dá)式;param2 將匹配的字符替換成指定字符;param3 模式

param3 參數(shù)如下

模式 i r m s c f
replace 支持 支持 只和r 組合 只和r 組合 只和r 組合 支持



模式解釋:

i: Case insensitive: 忽略大小寫

f: First only. That is, replace/find/etc. only the first occurrence of something.

r: The substring to find is a regular expression.標(biāo)準(zhǔn)正則表達(dá)式(http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

m: Multi-line mode for regular expressions. In multi-line mode the expressions ^ and $ match just after or just before, respectively, a line terminator or the end of the string. By default these expressions only match at the beginning and the end of the entire string. Note that ^ and $ doesn't match the line-break character itself.

s: Enables dot-all mode for regular expressions (same as Perl singe-line mode). In dot-all mode, the expression . matches any character, including a line terminator. By default this expression does not match line terminators.

c: Permits whitespace and comments in regular expressions.在正則表達(dá)式中允許空格和注釋。

范例如下:

<#assign s = 'foo bAr baar'>
${s?replace('ba', 'XY')}
i: ${s?replace('ba', 'XY', 'i')}
if: ${s?replace('ba', 'XY', 'if')}
r: ${s?replace('ba*', 'XY', 'r')}
ri: ${s?replace('ba*', 'XY', 'ri')}
rif: ${s?replace('ba*', 'XY', 'rif')} 

輸出結(jié)果:

foo bAr XYar
i: foo XYr XYar
if: foo XYr baar
r: foo XYAr XYr
ri: foo XYr XYr
rif: foo XYr baar 

更多范例:

原文:str = 2積分兌換30元優(yōu)惠券

${str?replace('\\b\\d+積分','','r')}

輸出:兌換30元優(yōu)惠券

ps:freemarker的replace功能

替換字符串 replace 

${s?replace(‘ba', ‘XY' )} 
${s?replace(‘ba', ‘XY' , ‘規(guī)則參數(shù)')}

將s里的所有的ba替換成xy 規(guī)則參數(shù)包含: i r m s c f 具體含義如下: 

· i: 大小寫不區(qū)分. 
· f: 只替換第一個(gè)出現(xiàn)被替換字符串的字符串 
· r:  XY是正則表達(dá)式 

· m: Multi-line mode for regular expressions. In multi-line mode the expressions ^ and $ match just after or just before, respectively, a line terminator or the end of the string. By default these expressions only match at the beginning and the end of the entire string. 

· s: Enables dotall mode for regular expressions (same as Perl singe-line mode). In dotall mode, the expression . matches any character, including a line terminator. By default this expression does not match line terminators. 

· c: Permits whitespace and comments in regular expressions. 

相關(guān)文章

  • SpringBoot?整合?Elasticsearch?實(shí)現(xiàn)海量級(jí)數(shù)據(jù)搜索功能

    SpringBoot?整合?Elasticsearch?實(shí)現(xiàn)海量級(jí)數(shù)據(jù)搜索功能

    這篇文章主要介紹了SpringBoot?整合?Elasticsearch?實(shí)現(xiàn)海量級(jí)數(shù)據(jù)搜索,本文主要圍繞?SpringBoot?整合?ElasticSearch?接受數(shù)據(jù)的插入和搜索使用技巧,在實(shí)際的使用過程中,版本號(hào)尤其的重要,不同版本的?es,對(duì)應(yīng)的?api?是不一樣,需要的朋友可以參考下
    2022-07-07
  • Java long 轉(zhuǎn)成 String的實(shí)現(xiàn)

    Java long 轉(zhuǎn)成 String的實(shí)現(xiàn)

    這篇文章主要介紹了Java long 轉(zhuǎn)成 String的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • Java調(diào)用明華RF讀寫器DLL文件過程解析

    Java調(diào)用明華RF讀寫器DLL文件過程解析

    這篇文章主要介紹了Java調(diào)用明華RF讀寫器DLL文件過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • Java事件處理機(jī)制(自定義事件)實(shí)例詳解

    Java事件處理機(jī)制(自定義事件)實(shí)例詳解

    這篇文章主要介紹了Java事件處理機(jī)制(自定義事件)實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • 如何修改覆蓋spring boot默認(rèn)日志策略logback詳解

    如何修改覆蓋spring boot默認(rèn)日志策略logback詳解

    這篇文章主要給大家介紹了關(guān)于如何修改覆蓋spring boot默認(rèn)日志策略logback的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-10-10
  • Springboot使用Security實(shí)現(xiàn)OAuth2授權(quán)驗(yàn)證完整過程

    Springboot使用Security實(shí)現(xiàn)OAuth2授權(quán)驗(yàn)證完整過程

    安全管理是軟件系統(tǒng)必不可少的的功能。根據(jù)經(jīng)典的“墨菲定律”——凡是可能,總會(huì)發(fā)生。如果系統(tǒng)存在安全隱患,最終必然會(huì)出現(xiàn)問題,這篇文章主要介紹了SpringBoot使用Security實(shí)現(xiàn)OAuth2授權(quán)驗(yàn)證完整過程
    2022-12-12
  • Java設(shè)計(jì)模式之命令模式(Command模式)介紹

    Java設(shè)計(jì)模式之命令模式(Command模式)介紹

    這篇文章主要介紹了Java設(shè)計(jì)模式之命令模式(Command模式)介紹,本文講解了Command模式的定義、如何使用命令模式等內(nèi)容,需要的朋友可以參考下
    2015-03-03
  • 簡(jiǎn)單總結(jié)單例模式的4種寫法

    簡(jiǎn)單總結(jié)單例模式的4種寫法

    今天帶大家學(xué)習(xí)java的相關(guān)知識(shí),文章圍繞著單例模式的4種寫法展開,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下
    2021-06-06
  • Java數(shù)據(jù)結(jié)構(gòu)常見幾大排序梳理

    Java數(shù)據(jù)結(jié)構(gòu)常見幾大排序梳理

    Java常見的排序算法有:直接插入排序、希爾排序、選擇排序、冒泡排序、歸并排序、快速排序、堆排序等。本文詳解介紹它們的實(shí)現(xiàn)以及圖解,需要的可以參考一下
    2022-03-03
  • Freemarker如何生成樹形導(dǎo)航菜單(遞歸)

    Freemarker如何生成樹形導(dǎo)航菜單(遞歸)

    這篇文章主要為大家詳細(xì)介紹了Freemarker采用的的方法生成樹形導(dǎo)航菜單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-09-09

最新評(píng)論