一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服務器之家 - 編程語言 - JAVA教程 - Freemaker Replace函數的正則表達式運用

Freemaker Replace函數的正則表達式運用

2020-03-12 11:14jerrylsxu JAVA教程

這篇文章主要介紹了Freemaker Replace函數的正則表達式運用 的相關資料,需要的朋友可以參考下

replace(param1,param2,param3)

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

param3 參數如下

 

模式 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.標準正則表達式(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.在正則表達式中允許空格和注釋。

范例如下:

?
1
2
3
4
5
6
7
<#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')}

輸出結果:

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元優惠券

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

輸出:兌換30元優惠券

ps:freemarker的replace功能

替換字符串 replace 

?
1
2
${s?replace(‘ba', ‘XY' )}
${s?replace(‘ba', ‘XY' , ‘規則參數')}

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

· i: 大小寫不區分. 
· f: 只替換第一個出現被替換字符串的字符串 
· r:  XY是正則表達式 

· 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. 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 和两个男人玩3p好爽视频 | 欧美日韩国产成人综合在线影院 | 亚洲香蕉网久久综合影院3p | 给我视频免费看 | 亚洲剧情在线观看 | 免费a视频在线观看 | 青草青青在线 | 日本96在线精品视频免费观看 | 99久久精品99999久久 | 特级一级全黄毛片免费 | chinese特色video | 日本玖玖视频 | 日本视频免费在线 | 美女无内裤下部黄 | 毛片免费网站 | 999热这里全都是精品 | 青青青青久久国产片免费精品 | 成人免费播放 | 99在线在线视频免费视频观看 | 免费在线观看小视频 | 国模一区二区三区视频一 | 99热在线观看免费 | 国外欧美一区另类中文字幕 | 爱爱小说漫画 | 欧美伦理影院 | 九九九国产在线 | 国产精品香蕉一区二区三区 | 国产一区视频在线免费观看 | 福利姬 magnet | 91视频无限看 | 四虎国产精品免费入口 | 国产大片免费在线观看 | 日本强不卡在线观看 | 久久AV喷吹AV高潮欧美 | 午夜免费无码福利视频麻豆 | 操儿子| 青青青在线免费 | 亚洲精品久久久WWW游戏好玩 | x8x8国产在线观看2021 | 日韩一区二区不卡 | 美女扒开奶罩让男人吃奶 |