0

I wanted to insert the records I had extracted from website to DB, but the extraction text contained the symbol apostrophe, and had caused me syntax error during sql insertion. May I know how to replace apostrophe with "’" instead in WebHarvest?

Thanks in advance!

Jazz
  • 21
  • 3

1 Answers1

0

I normally use the script element to work on strings, and then output to a new webharvest variable. For example:

    <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("&", "&amp;").replaceAll("\\t","").replaceAll("\\n","").replaceAll("\\r","");
           ]]>
        </script>
    </var-def>

    <var name="r_output2"/>

as a side note, instead of quoting your apostrophes in quotes it is much better to quote the whole chunk of data eg: "a string with a ' single quote" instead of a string with a "'" single quote

user3616725
  • 3,485
  • 1
  • 18
  • 27
  • If this has solved your problem, remember to click the "checkmark" icon on the left of the answer to accept it. – user3616725 Aug 16 '16 at 15:58