问题描述
所以我需要替换#var#和#var2#with < cfqueryparam value =#var#/>
和 ; cfqueryparam value =#var2#/>
。但是,只有当#var#包在< cfquery>< / cfquery>
内时才会发生。
So I need to replace #var# and #var2# with <cfqueryparam value="#var#" />
and <cfqueryparam value="#var2#" />
. However, this should only happen when #var# is wrapped inside <cfquery></cfquery>
.
作为额外的标准,cfquery-tag将在哈希符号之前和之后包含文本。这是一个示例:
As an extra criteria, the cfquery-tag will contain text before and after the hash-symbols. This is an example:
<cfquery datasource="#tablename#">
SELECT * FROM table WHERE name = #var#, somethingelse = #var2#;
</cfquery>
我需要一个正则表达式,只有匹配'test'哈希符号和可能有或没有属性的cfquery-tag内部。
I need a regex that only matches 'test' when it's between two hash-symbols and inside a cfquery-tag that may or may not have attributes.
我使用grepWin来替换。
I'm using grepWin to do the replacement.
推荐答案
使用regex的另一个解决方案:
match:
(#[^#><]*#)(?=[^>]*<\/cfquery>)
并替换为:
<cfqueryparam value="$1" />
请参阅
这篇关于RegEx可以替换两个哈希符号之间的文本,两个标签之间,但保持一切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!