Help me create a Macro

Started by: prashob122 voices5 posts

Hello:

Please help me to create a macro:

I want to delete the follwoing:

(<[^>]+>){1,20} (empty elements)

but there is a condition i want to delete the above only when it comes in the following parent element i.e..

....


For e.g.

BUNDESARBEITSGERICHT

URTEIL


The above should apply to all the XML files in a particular path.

Thanks in Advance
Please Reply someone can solve this problem & help me out

prashob12 wrote:
Hello:

Please help me to create a macro:

I want to delete the follwoing:

(]+>){1,20} (empty elements)

but there is a condition i want to delete the above only when it comes in the following parent element i.e..

....


For e.g.

BUNDESARBEITSGERICHT

URTEIL


The above should apply to all the XML files in a particular path.

Thanks in Advance

Go to Customize > Search tab, and check "Regular Expressions Can Match New Line Characters", and set "Additional Lines to Search for Regular Expressions" to 10.

Find:
(.*?)(]+>){1,20}(.*?)

Replace with:
13

Thanks a lot for replying

I tried what u told, but the number of Empty elements present in the is many, so if i use the replacment option it deletes one instance at a time, and the number of files with such instances are also many, so it will be time consuming.

I created a macro to replace all empty elements in at one go:

document.selection.Find("",eeFindNext | eeFindReplaceRegExp);
document.selection.CharLeft(false,1);
editor.ExecuteCommandByID(4153);
document.selection.Find("",eeFindNext | eeFindReplaceRegExp);
document.selection.Replace("(]+>){1,20}","",eeFindNext | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp);
document.selection.Replace("","",eeFindNext | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp);
document.selection.CharRight(false,1);

But i dont know how to make it run on all the files.
There are 1000's of such files.

Thanks in Advance!!

prashob12 wrote:
Thanks a lot for replying

I tried what u told, but the number of Empty elements present in the is many, so if i use the replacment option it deletes one instance at a time, and the number of files with such instances are also many, so it will be time consuming.

I created a macro to replace all empty elements in at one go:

document.selection.Find("",eeFindNext | eeFindReplaceRegExp);
document.selection.CharLeft(false,1);
editor.ExecuteCommandByID(4153);
document.selection.Find("",eeFindNext | eeFindReplaceRegExp);
document.selection.Replace("(]+>){1,20}","",eeFindNext | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp);
document.selection.Replace("","",eeFindNext | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp);
document.selection.CharRight(false,1);

But i dont know how to make it run on all the files.
There are 1000's of such files.

Thanks in Advance!!

If you have so many files, how about ReplaceInFiles Method (Editor object)?

5 posts in this topic