I'm pretty inexperienced with RegEx - just a random regExforward RegEx for a programming task that I developed by trial and error, but now I have a serious regEx problem:
I have about 970 text files containing Sybase Transact SQL fragments, and I need to find each table name in these files and preface the table name with "#". Therefore, my options are either to spend a week editing the files manually, or to write a script or application using regEx (Python 3 or Delphi-PRCE) that will perform this task.
The rules are as follows:
Table names are ALWAYS - upper case - so I'm only looking for upperCase words;
Column names, SQL expressions, and variables ALWAYS lowerCase;
SQL keywords, table aliases, and column values ββMAY BE upperCase, but MUST NOT have the prefix '#';
Table aliases (must not have a prefix) will always have a white space in front of them until the end of the previous word, which will be the name of the table.
Column values ββ(must not have a prefix) will be either numerical values ββor characters enclosed in quotes.
Here is an example of a text requiring all of the above rules to apply:
update SYBASE_TABLE
set ok = convert(char(10),MB.limit)
from MOVE_BOOKS MB, PEOPLEPLACES PPL
where MB.move_num = PPL.move_num
AND PPL.mot_ind = 'B'
AND PPL.trade_type_ind = 'P'
So far I only got this far (not too far ...)
- [[: upper:]] (me?)
Any help would be greatly appreciated. TIA
Mn