editor.replace can't find ; character

  • L&E Destock

    L&E Destock - 2012-05-31


    I try to replace a sentence with another both including some     ;   character inside but it doesn't work , when I delete that character then the script works but I need that character to be included.

    Here is the code I use :

    editor.replace("\"Parent";"- bad_br7001";"\"", "\"Parent";"bad_br7001";"TU\"")

    I'd like to replace
    >        "Parent";"- bad_br7001";""

    by that >   "Parent";"- bad_br7001";"TU"

    thanks for your help

  • Dave Brotherstone

    It's not the ; that's the problem, it's the quote immediately before it.  You need to escape every quote that's in your string, or, because Python is great, you can just use a single quote, and then you don't need to escape your double quotes.

    So, easiest:

    editor.replace('"Parent";"- bad_br7001";""', '"Parent";"bad_br7001";"TU"')

    or, to correct your version:

    editor.replace("\"Parent\";\"- bad_br7001\";\"\"", "\"Parent\";\"bad_br7001\";\"TU\"")

    You can see from the syntax highlighting that it thinks the string is ended before the semi-colon, because the semi colon is coloured differently.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks