国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

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

2019-11-14 22:24:53
字體:
來源:轉載
供稿:網友
Freemaker Replace函數的正則表達式運用

replace(param1,param2,param3)

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

param3參數如下

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

范例如下:

<#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 XYari: foo XYr XYarif: foo XYr baarr: foo XYAr XYrri: foo XYr XYrrif: foo XYr baar 

更多范例:

原文:str = 2積分兌換30元優惠券${str?replace('//b//d+積分','','r')} 輸出:兌換30元優惠券

更多信息可以參考:

http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_replace


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日照市| 望奎县| 全南县| 隆回县| 绥宁县| 木里| 孙吴县| 财经| 胶南市| 台湾省| 武川县| 夏津县| 靖西县| 松桃| 遂平县| 响水县| 汽车| 德安县| 宁波市| 大足县| 南靖县| 临漳县| 茶陵县| 青龙| 永泰县| 濮阳县| 壤塘县| 中西区| 宝山区| 望城县| 三江| 定南县| 娄烦县| 江华| 黎平县| 汝州市| 西城区| 古田县| 荣成市| 大余县| 阜南县|