我想将从网站提取的记录插入到数据库中,但提取的文本包含符号撇号,并在sql插入过程中导致语法错误。我可以知道在WebHarvest中如何用“‘”代替撇号吗?
提前感谢!
发布于 2016-04-06 19:36:26
我通常使用script元素来处理字符串,然后将其输出到一个新的web获取器变量。例如:
<var-def name="r_output">
A long string with lots of funny characters
new lines and & and ' single and " double quotes
</var-def>
<var-def name="r_output2">
<script return="r_output2">
<![CDATA[
String r_output2 = "\n" + r_output.toString().replaceAll("&", "&").replaceAll("\\t","").replaceAll("\\n","").replaceAll("\\r","");
]]>
</script>
</var-def>
<var name="r_output2"/>顺便说一句,与其用引号将撇号引起来,不如引用整个数据块,例如:"a string with a ' single quote"而不是a string with a "'" single quote
https://stackoverflow.com/questions/31231987
复制相似问题