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",
"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,
Dave.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
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",
"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,
Dave.
Sorry to come back again to you but the script doesn't work , it doesn't even launch when I use this code :
editor.replace("é","é")
editor.replace("è","è")
editor.replace("ê","ê")
editor.replace("ë","ë")
editor.replace("ç","ç")
editor.replace("à","à")
editor.replace("â","â")
editor.replace("î","î")
editor.replace("ô","ô")
Do you have any idea why ? : /
By doing this I want to change every special characters into HTML code
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;
I tried by adding
# coding= UTF-8
To the first line , now the scripts launch but it doesn't change any special character.
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 =))