User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with writing and playing macros
3 posts Page 1 of 1
I have a whole set of regexes given below which I want to run all together instead of running each one separately. These allow me to check for mismatches within a dictionary and ensure that a wrong word is not mapped to the headword entry.
I tried to write a macro with each regex listed and with a loop to for each but it did not work too well.
I am giving below a sample list of regexes which I want to run:
Code: Select all
%a*=[~अआएऐऔओऍ]*$
%b*=[~बभ]*$
%c*=[~चछसकक]*$
%d*=[~दडधढज्ञ]*$
%e*=[~एइईऐ]*$
%f*=[~फफ़]*$
%g*=[~गग़घज]*$
%h*=[~ह]*$
%i*=[~अआइई]*$
%j*=[~जज़झ]*$
%k*=[~कक़खख़]*$
%l*=[~ल]*$
%m*=[~म]*$
%n*=[~न]*$
%o*=[~ओआऑउऊ]*$
%p*=[~पफफ़]*$
%q*=[~क़क]*$
%r*=[~रऋहृ]*$
%s*=[~सशष]*$
%t*=[~तटथठ]*$
%u*=[~अयउऊ]*$
%v*=[~व]*$
%w*=[~व]*$
%y*=[~य]*$
%z*=[~ज़जझ]*$

Many thanks in advance for help and all good wishes for the New Year to all forum members who are so helpful especially Mofi, and take their time off to solve problems.
I do not understand what you want from us. You can simply record a macro on executing once the finds or replaces manually.

For example I run with your strings UltraEdit regular expression Replace All commands with UE v20.00.0.1056 and recorded those replaces to a macro attached to this post. It could be that you cannot open this macro file when using an older version of UltraEdit. UltraEdit records non ASCII characters encoded in UTF-8. In edit macro dialog they are displayed as UTF-8 byte sequences without conversion back to Unicode.

As script created with help of Creating a Perl regular expression string with ANSI/Unicode characters.

Code: Select all
if (UltraEdit.document.length > 0)  // Is any file opened?
{
   // Define environment for this script.
   UltraEdit.insertMode();
   UltraEdit.columnModeOff();
   // Move caret to top of the active file.
   UltraEdit.activeDocument.top();

   // Define the parameters for the Perl regular expression Replace All commands.
   UltraEdit.perlReOn();
   UltraEdit.activeDocument.findReplace.mode=0;
   UltraEdit.activeDocument.findReplace.matchCase=true;
   UltraEdit.activeDocument.findReplace.matchWord=false;
   UltraEdit.activeDocument.findReplace.regExp=true;
   UltraEdit.activeDocument.findReplace.searchDown=true;
   if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean") {
      UltraEdit.activeDocument.findReplace.searchInColumn=false;
   }
   UltraEdit.activeDocument.findReplace.preserveCase=false;
   UltraEdit.activeDocument.findReplace.replaceAll=true;
   UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;

   // Run the Perl regular expression Replace All commands.
   UltraEdit.activeDocument.findReplace.replace("^a.*?=[^\\x{0905}\\x{0906}\\x{090f}\\x{0910}\\x{0914}\\x{0913}\\x{090d}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^b.*?=[^\\x{092c}\\x{092d}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^c.*?=[^\\x{091a}\\x{091b}\\x{0938}\\x{0915}\\x{0915}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^d.*?=[^\\x{0926}\\x{0921}\\x{0927}\\x{0922}\\x{091c}\\x{094d}\\x{091e}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^e.*?=[^\\x{090f}\\x{0907}\\x{0908}\\x{0910}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^f.*?=[^\\x{092b}\\x{092b}\\x{093c}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^g.*?=[^\\x{0917}\\x{0917}\\x{093c}\\x{0918}\\x{091c}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^h.*?=[^\\x{0939}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^i.*?=[^\\x{0905}\\x{0906}\\x{0907}\\x{0908}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^j.*?=[^\\x{091c}\\x{091c}\\x{093c}\\x{091d}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^k.*?=[^\\x{0915}\\x{0915}\\x{093c}\\x{0916}\\x{0916}\\x{093c}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^l.*?=[^\\x{0932}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^m.*?=[^\\x{092e}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^n.*?=[^\\x{0928}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^o.*?=[^\\x{0913}\\x{0906}\\x{0911}\\x{0909}\\x{090a}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^p.*?=[^\\x{092a}\\x{092b}\\x{092b}\\x{093c}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^q.*?=[^\\x{0915}\\x{093c}\\x{0915}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^r.*?=[^\\x{0930}\\x{090b}\\x{0939}\\x{0943}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^s.*?=[^\\x{0938}\\x{0936}\\x{0937}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^t.*?=[^\\x{0924}\\x{091f}\\x{0925}\\x{0920}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^u.*?=[^\\x{0905}\\x{092f}\\x{0909}\\x{090a}].*$", "");
   UltraEdit.activeDocument.findReplace.replace("^v*.?=[^\\x{0935}]*.$", "");
   UltraEdit.activeDocument.findReplace.replace("^w*.?=[^\\x{0935}]*.$", "");
   UltraEdit.activeDocument.findReplace.replace("^y*.?=[^\\x{092f}]*.$", "");
   UltraEdit.activeDocument.findReplace.replace("^z*.?=[^\\x{091c}\\x{093c}\\x{091c}\\x{091d}]*.$", "");
}

And the script code as macro code.

Code: Select all
InsertMode
ColumnModeOff
Top
PerlReOn
Find MatchCase RegExp "^a.*?=[^\x{0905}\x{0906}\x{090f}\x{0910}\x{0914}\x{0913}\x{090d}].*$"
Replace All ""
Find MatchCase RegExp "^b.*?=[^\x{092c}\x{092d}].*$"
Replace All ""
Find MatchCase RegExp "^c.*?=[^\x{091a}\x{091b}\x{0938}\x{0915}\x{0915}].*$"
Replace All ""
Find MatchCase RegExp "^d.*?=[^\x{0926}\x{0921}\x{0927}\x{0922}\x{091c}\x{094d}\x{091e}].*$"
Replace All ""
Find MatchCase RegExp "^e.*?=[^\x{090f}\x{0907}\x{0908}\x{0910}].*$"
Replace All ""
Find MatchCase RegExp "^f.*?=[^\x{092b}\x{092b}\x{093c}].*$"
Replace All ""
Find MatchCase RegExp "^g.*?=[^\x{0917}\x{0917}\x{093c}\x{0918}\x{091c}].*$"
Replace All ""
Find MatchCase RegExp "^h.*?=[^\x{0939}].*$"
Replace All ""
Find MatchCase RegExp "^i.*?=[^\x{0905}\x{0906}\x{0907}\x{0908}].*$"
Replace All ""
Find MatchCase RegExp "^j.*?=[^\x{091c}\x{091c}\x{093c}\x{091d}].*$"
Replace All ""
Find MatchCase RegExp "^k.*?=[^\x{0915}\x{0915}\x{093c}\x{0916}\x{0916}\x{093c}].*$"
Replace All ""
Find MatchCase RegExp "^l.*?=[^\x{0932}].*$"
Replace All ""
Find MatchCase RegExp "^m.*?=[^\x{092e}].*$"
Replace All ""
Find MatchCase RegExp "^n.*?=[^\x{0928}].*$"
Replace All ""
Find MatchCase RegExp "^o.*?=[^\x{0913}\x{0906}\x{0911}\x{0909}\x{090a}].*$"
Replace All ""
Find MatchCase RegExp "^p.*?=[^\x{092a}\x{092b}\x{092b}\x{093c}].*$"
Replace All ""
Find MatchCase RegExp "^q.*?=[^\x{0915}\x{093c}\x{0915}].*$"
Replace All ""
Find MatchCase RegExp "^r.*?=[^\x{0930}\x{090b}\x{0939}\x{0943}].*$"
Replace All ""
Find MatchCase RegExp "^s.*?=[^\x{0938}\x{0936}\x{0937}].*$"
Replace All ""
Find MatchCase RegExp "^t.*?=[^\x{0924}\x{091f}\x{0925}\x{0920}].*$"
Replace All ""
Find MatchCase RegExp "^u.*?=[^\x{0905}\x{092f}\x{0909}\x{090a}].*$"
Replace All ""
Find MatchCase RegExp "^v*.?=[^\x{0935}]*.$"
Replace All ""
Find MatchCase RegExp "^w*.?=[^\x{0935}]*.$"
Replace All ""
Find MatchCase RegExp "^y*.?=[^\x{092f}]*.$"
Replace All ""
Find MatchCase RegExp "^z*.?=[^\x{091c}\x{093c}\x{091c}\x{091d}]*.$"
Replace All ""

The advantage of using Perl regular expression is the possibility to code the Unicode characters in ASCII with \x{4-digit hex value} which makes it possible to code them in scripts easily (using my referenced script) or macros.

I think, with all the macros and scripts I wrote already for you, you should be already able to code such simple scripts/macros by yourself.

Edit: ZIP file with the recorded macro removed after reply by dictdoc.
Best regards from Austria
Many thanks for the advice. I have an old version of UE and I think it is high-time I upgrade to the latest one.
Thanks once again for your help and advice.
3 posts Page 1 of 1
cron