[SOLVED] editor.replace with quotes

  • L&E Destock

    L&E Destock - 2012-05-18


    I would like to ask you something about the Python script.
    I'm actualy using it only to mass  Search/Replace  text in
    huge files.

    So I'm using for example :   editor.replace("MICHAEL",

    the issue comes when I need to replace some text that is
    already between " " ,  so here is something I tried but it
    didn't work :

    example :   editor.replace(""HELLO"", ""Hello"")
    As you can see I try to replace "HELLO" by "Hello" , that's
    why I duplicated the " " , but it doesn't work , do you have
    any idea on how to fix that issue ?

    Could I change the default  separator "  "   with   / /
    So I'd have :

    editor.replace(/"HELLO"/, /"Hello"/)

    if yes where can I make that change ?

    Thanks :)

    ANSWERED BY  davegb3 :

    You don't need to escape quotes around normal text -e.g.  editor.replace("MICHAEL","Michael")

    To put a quote in it, just escape the quote that's inside the text
    editor.replace("\"MICHAEL\"", "\"Michael\"")

    Note that you can also use the other form of quotes to quote stuff. That's a nice feature of
    python, is that it allows you to use the quotes that mean the other form doesn't need
    escaping -e.g.
    editor.replace('"Michael"', '"MICHAEL"');

    Hope that helps,

  • L&E Destock

    L&E Destock - 2012-05-18

    Sorry to come back again to you but the script  doesn't work , it doesn't even launch when I use this code :


    Do you have any idea why ? : /

    By doing this I want to change every special characters into HTML code

  • L&E Destock

    L&E Destock - 2012-05-18

    SyntaxError: Non-ASCII character '\xe9' in file C:\Documents and Settings\Administrator\Application Data\Notepad++\plugins\Config\PythonScript\scripts\marques.py on line 1, but no encoding declared;

  • L&E Destock

    L&E Destock - 2012-05-18

    I tried by adding 

    # coding= UTF-8

    To the first line , now the scripts launch but it doesn't change any special character.

  • L&E Destock

    L&E Destock - 2012-05-18

    my .py file was ANSI coding , I changed it into UTF-8 and it looks like it's working now… I'll get back soon here if I've any issue  =))


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

Sign up for the SourceForge newsletter:

No, thanks