Regex for %Table() Meta-SQL

I've come up with the following regular expressions to add or remove %Table() meta-sql construct. Applications might involve using it to replace standard table names with the %Table() Meta-SQL directive before putting them into the Application Designer SQL Editor or using it to remove the %Table() Meta-SQL directive if you don't have the option to resolve meta-sql. It's also just a good example of regex to match the start and end of a qualifier like brackets and replace them with something else.

Here are the four scenarios that you might have:

Regular PeopleSoft Tables

This is for anything that uses PS_ in your database as a prefix:

Find something like PS_INSTALLATION and replace with %Table(INSTALLATION)

Find Regex: PS_([^\s]*)
Replace Regex: %Table($1)

Find something like %Table(INSTALLATION) and replace with PS_INSTALLATION

Find Regex: %Table\(((?!PS)[^\s]*)\)
Replace Regex: PS_$1

PeopleTools Tables

This is specifically for PeopleTools tables that always start with PS and do not use the PS_ prefix for the database table name.

Find something like PSOPRDEFN and change to %Table(PSOPRDEFN)

Find Regex: PS((?!_)[^\s]*)
Replace Regex: %Table(PS$1)

Find something like %Table(PSOPRDEFN) and change to PSOPRDEFN

Find Regex: %Table\(((PS)[^\s]*)\)
Replace Regex: $1

How to use

Try it out in your text editor with regular expressions enabled. You may need to put qualifiers around the find regex, e.g. /%Table\(((PS)[^\s]*)\)/g depending on the regex engine you are using.

Also you can try these out using RegExr online to see them in action.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License