你如何将Regex子表达式匹配分割成多维字符串数组?
我有一个"myvar"字符串:
1-4:2;5-9:1.89;10-24:1.79;25-99:1.69;100-149:1.59;150-199:1.49;200-249:1.39;250+:1.29
这是重复的 QuantityLow - QuantityHigh : PriceEach ;
我使用了这个"myreg"正则表达式 /(\d+)[-+](\d*):(\d+\.?\d*);?/g
用它 var myarray = myvar.match(myreg);
产生的:
myarray[0] = "1-4:2;"
myarray[1] = "5-9:1.89;"
myarray[2] = "10-24:1.79;"
myarray[3] = "25-99:1.69;"
myarray[4] = "100-149:1.59;"
myarray[5] = "150-199:1.49;"
myarray[6] = "200-249:1.39;"
myarray[7] = "250+:1.29"
太棒了!除了我需要在Q1-Q2:P之外进一步打破弦乐,如上所述.正则表达式已设置为使用括号标识零件.我认为这可以使用单个Regex表达式,或至少两个,而不是设置某种循环.
感谢您的反馈.
我正在使用CF8和SQL2000.我在SQL表的Text字段中存储了一堆HTML.当我针对该数据执行简单的CFQUERY以及CFDUMP时,它被截断为64000个字符.
通过使用SELECT Substring选择数据的尾端,我已经确认我的数据在SQL表中是完整的,并使用SELECT Datalength()确认了长度.这真的是65102个字符.
这是CFQUERY的限制,如果是这样,有什么好办法?
如何在不使用ColdFusion中的Results.columnname的情况下打印所有结果
对于前: -
我有 <cfquery name="getProductId">
select productId
from product
</cfquery>
在Product Table中,我有2列product_name和Product_id.
如何在不使用getProductId.product_name getProductId.Product_id的情况下打印它们
谢谢,
我在CFC文件中有一个函数,它将从.cfm文件中调用,如下所示
<cffunction name="cftest" access="public" returntype="query" output="true" hint="Function returns Records">
<cfquery name="qryTest" datasource="DBTest">
select * from emp_tab;
</cfquery>
<cfreturn selectRecordsResultSet />
</cffunction>
Run Code Online (Sandbox Code Playgroud)
如何使用cftry处理数据库异常?因为这是返回Query,是否有可能捕获数据库异常并将详细信息传递到调用它的其他页面?
谢谢
我需要解析一个段落(字符串)中的所有URL,
例如.
"看看这个网站google.com,别忘了看到这个太bing.com/maps"
它应该返回"google.com和bing.com/maps"
我目前正在使用它,而不是完美.
reMatch("(^|\s)[^\s@]+\.[^\s@\?\/]{2,5}((\?|\/)\S*)?",mystring)
Run Code Online (Sandbox Code Playgroud)
谢谢
我最近学到了一点Python,我找不到一个很好的RegEx列表(不知道这是否是正确的复数时......)完整的解释,即使菜鸟会理解:)
有谁知道这样的名单?
在ColdFusion结构(数组)中创建密钥的正确语法是什么?最好是在cfscript标签中.
为了更清楚地了解我想要做什么,这就是我认为的可能:
StructInsert(account[i], "child[numChildren]", z);
Run Code Online (Sandbox Code Playgroud)
其中"child"应该是一个数组,numChildren是一个循环中的计数器.
显然这不起作用.它只是给我一个错误,说关键字"child [numChildren]"已经存在.
如果我把:
this.securejson = true;
Run Code Online (Sandbox Code Playgroud)
进入我的Application.cfc,然后我的$ .ajax函数调用不回调.done函数.
如果我关闭securejson,它会工作.
是否有一种已知的方法可以在ajax中使用securejson?
我在ColdFusion 9中的变量中存储了以下HTML.我需要在第4个之后插入一个新的表行</tr>.即在提交按钮之前.
<form name="form1" id="form1" action="" method="post">
<table>
<tr style="visibility:hidden;display:none;"><td> <input type="hidden" id="ref1" name="ref1" value="1" > </td></tr>
<tr style="visibility:hidden;display:none;"><td> <input type="hidden" id="ref2" name="ref2" value="2" > </td></tr>
<tr>
<th style="text-align:left;">Name * </th>
<td><input type="text" name="foo" id="foo" size="30" maxlength="50" value=""></td>
</tr>
<tr>
<th title="Please enter plain text or HTML." style="cursor:help;text-align:left;">Comment * </th>
<td><textarea name="bar" id="bar" cols="40" rows="10" ></textarea></td>
</tr>
<tr>
<th colspan="1"></th>
<td>
<input style="width:80px" type="submit" value="Submit">
<input style="width:80px" type="button" value="Cancel">
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
ReReplace似乎是要走的路,但是我无法正确使用正则表达式.另一个选择是拆分字符串并使用我的新HTML在中间重建它.任何建议,将不胜感激.
我需要从结构数组中创建一个查询对象.该阵列有大约200个键,阵列内部的结构在名称,大小和深度上有所不同.这是一个节点的样子:

我已经让它适用于数组[#i] .adGroupId和数组[#i#].userStatus但我需要在将结构值添加到查询之前检查它是否存在.criterion.text例如并不总是在结构中,所以我需要检查,但不知道如何.这是迄今为止的代码,但它总是跳过criterion.text和bids.maxCpc.amount.microAmount.
<cfset vColumns = "AdGroupID,KeywordText,Status,MaxCPC" />
<cfset vColumnValue = "AdGroupID,criterion.text,userStatus,bids.maxCPC" />
<cfset loopnum = 1>
<cfset myquery = QueryNew(vColumns) >
<cfloop array="#aKeywordsAll#" index="i">
<cfset temp = QueryAddRow(myquery, 1)>
<cfset loopNum2 = 1>
<cfloop list="#vColumnValue#" index="j">
<cfif structKeyExists(aKeywordsAll[loopnum],j)>
<cfset QuerySetCell(myquery, listGetAt(vColumns, loopNum2), aKeywordsAll[loopnum][j])>
<cfelse>
<cfset QuerySetCell(myquery, listGetAt(vColumns, loopNum2), "test")>
</cfif>
<cfset loopNum2++ />
</cfloop>
<cfset loopnum++ />
</cfloop>
Run Code Online (Sandbox Code Playgroud)
这是创建的查询对象.它说"测试",但希望它能给出值:

coldfusion ×8
regex ×4
coldfusion-9 ×3
cfquery ×2
ajax ×1
arrays ×1
cfadmin ×1
cfc ×1
html-parsing ×1
javascript ×1
jquery ×1
python ×1
sql ×1
url ×1