We have a database where every table name starts with WW.
I want to display an SQL on a web page, but wrap each table name with a link.
For example:
"select * from wwx_something where ..."
Should be transformed into:
"select * from <a href='/table/wwx_something/'>wwx_something</a> where ..."
There might be several tables, of course, and it should not be case-sensitive.
I need a javascript regex solution…I can’t seem to get it to work.
Solution using a single replace:
note that I also tentative support for stuff such like “SELECT * FROM wwa JOIN wwb”.
ADDED after comment: yes, you can replace with a custom function in order to uppercase the URL:
PS: IMHO it’s better to include FROM/JOIN in the match because this way you’re better warded about strays “ww” that have nothing to do with table names… including a bit of context always helps disambiguate.