Page 1 of 1
Document.ReplaceAll not working
Posted: 28 Feb 2019 15:13
by kosthala
Hello,
I have created a very simple Pascal script in order to remove trailing spaces:
Code: Select all
begin
Document.ReplaceAll('^[ \t]+','', false, false, true);
end.
But when i run the script nothing happens. In previous versions the script was working fine.
Can you help me?
Re: Document.ReplaceAll not working
Posted: 28 Feb 2019 17:57
by Rickard Johansson
To remove trailing white spaces you could use something like:
Code: Select all
Document.ReplaceAll("[ \\t]+$", "", false, false, true);
or
Document.ReplaceAll('[ \t]+$', '', false, false, true); // Pascal
Re: Document.ReplaceAll not working
Posted: 01 Mar 2019 08:08
by kosthala
I'm sorry, i meant leading spaces...which is not working
Code: Select all
begin
Document.ReplaceAll('^[ \t]+','', false, false, true);
end.
Re: Document.ReplaceAll not working
Posted: 01 Mar 2019 16:58
by Rickard Johansson
I can't see anything wrong. Maybe your not executing the script correctly...
For testing and developing:
1. Enable dual document view and open the script in the left pane.
2. Open a test file, to execute the script on, to the right.
Now, run the script.
Re: Document.ReplaceAll not working
Posted: 01 Mar 2019 22:09
by kosthala
I followed your instructions and i get the attached message
Re: Document.ReplaceAll not working
Posted: 02 Mar 2019 08:50
by Rickard Johansson
If you create a new pascal script from the script menu you should get something like this:
Code: Select all
// Pascal script
// Global variables
// Enter code here
begin
end.
Insert your code between the begin .. end block.
E.g.
Code: Select all
// Pascal script
// Global variables
// Enter code here
begin
Document.ReplaceAll('^[ \t]+','', false, false, true);
end.
Re: Document.ReplaceAll not working
Posted: 02 Mar 2019 12:53
by kosthala
Please see my first post, i have already include begin - end pair.
Re: Document.ReplaceAll not working
Posted: 02 Mar 2019 14:18
by pjj
FWIW Rickard's script works for me well.
Re: Document.ReplaceAll not working
Posted: 02 Mar 2019 16:27
by kosthala
This is very weird. I copy the code from Rickard's script's and now is working.
But my first post script was exactly the same as Rickard's.
![Confused :?](./images/smilies/icon_confused.gif)