[英]Regular Expression to preserve quotes , single quotes , hyphens and split at white space
[英]Regular Expression to replace multiple hyphens with a single one
我写了一个正则表达式,生成一个类似
/abc/deutschland/bbs-tagesfahrten/betz-mode-frotier-center-–-tress-teigwaren.html.
现在,我想用一个破折号代替一个破折号。 我怎样才能?
String.replaceAll("--+", "-");
任何建议可能更简单:
s/-{2,}/-/g
用这个:
s/---*/-/g
要替换整个URL中的所有重复破折号,请执行以下操作:
<cfset InputUrl = "/abc/deutschland/bbs-tagesfahrten/betz-mode-frotier-center-–-tress-teigwaren.html">
<cfset CleanUrl = REReplace(InputUrl, "-+", "-", "ALL")>
要仅处理文件部分:
<cfset PathPart = REReplace(InputUrl, "(.*/).*", "\1")>
<cfset FilePart = ListLast(InputUrl, "/")>
<cfset CleanUrl = PathPart & REReplace(FilePart, "-+", "-", "ALL")>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.