I have a bunch of COBOL programs that I would like to bulk edit. Specifically replacing any COBOL reserved words with their upper case equivalents, and any non-reserved words with lower case equivalents. I have the list of reserved words. Can UltraEdit do that?
This can be done with UltraEdit using Perl regular expression Replace in Files.
For example the Perl regular expression search string \<(abc|def|xyz)\> finds with option Match case NOT checked one of the 3 words in the OR expression within capturing group 1 being an entire word and with replace string \U\1\E the found words are converted to upper case.
But please note that the number of words in OR is not unlimited. So perhaps you need multiple executions of this Perl regular expression replace in files with different lists of words depending on number of reserved COBOL words. I used in the past always 50 words at once in OR expression, but most likely there are much more possible.
After converting all reserved COBOL words in all COBOL source files to upper case, one more Perl regular expression Replace in Files can be used to convert all other words to lower case. This must be done with a single replace. If the list of reserved works is too large for the search expression below, a work around solution would be necessary and I know already which one. But let us assume here on first reply the number of reserved words is not too large for a single Perl regular expression Replace in Files.
The search string would be \<(\w+)\>(?<!ABC|DEF|XYZ) and the replace string \L\1\E for converting all non reserved words to lower case.
On looking on cobol.uew it looks like COBOL interprets - as word character. In this case \w+ must be replaced by [\w\-]+ in search string.