如何将 regex101 中的工作正则表达式转换为 Coldfusion
How can I convert a working regular expression in regex101 to Coldfusion
[https://regex101.com/r/qNDKIh/1/][1]
如何将 regex101 中的工作正则表达式转换为 Coldfusion REMatchNoCase
[1]: https://regex101.com/r/qNDKIh/1/
Coldfusion Code
<cfset VinDetail = ReMatchNoCase("^([A-HJ-NPR-Z0-9]{3})([A-HJ-NPR-Z0-9]{5})([0-9X])([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9]{6})$", "1G1PA5SH9D7126083") />
<cfdump var="#VinDetail#">
出现 Malformed regular expression
错误
Regex101 输出
Full match 0-17 1G1PA5SH9D7126083
Group `wmi` 0-3 1G1
Group `vds` 3-8 PA5SH
Group `check` 8-9 9
Group `vis` 9-17 D7126083
Group `year` 9-10 D
Group `plant` 10-11 7
Group `seq` 11-17 126083
匹配输入字符串的单个结果是'correct'——因为ReMatch()
只有return匹配,这才是真正的匹配。如果你想 return 捕获组,那么你可以使用 ReFind()
和 returnsubexpressions=true
,例如:
<cfset VinDetail2 = ReFindNoCase("^([A-HJ-NPR-Z0-9]{3})([A-HJ-NPR-Z0-9]{5})([0-9X])(([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9]{6}))$", "1G1PA5SH9D7126083", 1,true,'ALL') />
<cfdump var="#VinDetail2[1].MATCH#" />
<cfdump var="#VinDetail2#" />
[https://regex101.com/r/qNDKIh/1/][1]
如何将 regex101 中的工作正则表达式转换为 Coldfusion REMatchNoCase [1]: https://regex101.com/r/qNDKIh/1/
Coldfusion Code
<cfset VinDetail = ReMatchNoCase("^([A-HJ-NPR-Z0-9]{3})([A-HJ-NPR-Z0-9]{5})([0-9X])([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9]{6})$", "1G1PA5SH9D7126083") />
<cfdump var="#VinDetail#">
出现 Malformed regular expression
错误
Regex101 输出
Full match 0-17 1G1PA5SH9D7126083
Group `wmi` 0-3 1G1
Group `vds` 3-8 PA5SH
Group `check` 8-9 9
Group `vis` 9-17 D7126083
Group `year` 9-10 D
Group `plant` 10-11 7
Group `seq` 11-17 126083
匹配输入字符串的单个结果是'correct'——因为ReMatch()
只有return匹配,这才是真正的匹配。如果你想 return 捕获组,那么你可以使用 ReFind()
和 returnsubexpressions=true
,例如:
<cfset VinDetail2 = ReFindNoCase("^([A-HJ-NPR-Z0-9]{3})([A-HJ-NPR-Z0-9]{5})([0-9X])(([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9])([A-HJ-NPR-Z0-9]{6}))$", "1G1PA5SH9D7126083", 1,true,'ALL') />
<cfdump var="#VinDetail2[1].MATCH#" />
<cfdump var="#VinDetail2#" />