假如有如下json文件:
{ "Result": [ { "country": "TW", "mcc": "466", "chatUrl": "https://motorola-global-chn.custhelp.com/" }, { "country": "AU", "mcc": "505", "chatUrl": "https://motorola-global-en-aus.custhelp.com/" }, { "country": "NZ", "mcc": "530", "chatUrl": "https://motorola-global-en-aus.custhelp.com/" }, { "country": "AT", "mcc": "232", "chatUrl": "https://motorola-global-en-roe.custhelp.com/" }, { "country": "BE", "mcc": "206", "chatUrl": "https://motorola-global-en-roe.custhelp.com/" }, ...我们需要将其中的chatUrl全部替换成
https://motorola-global-portal--dev2.custhelp.com/我们可以在idea中或者文件编辑器如notepad中完成这项操作。使用字符串匹配并且开启使用正则表达式匹配的模式,我们使用匹配字符串开头和结尾的方式来完成字符串的替换。那么我们需要匹配所有:
以https://开头的并且以.com/结尾的字符串匹配上述模式的正则表达式是:
https://.+.com/也就是,我们使用下面的方式:
开头字符串.+.结尾字符串的模式来完成匹配。