Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Trying to match non-quoted sections

$
0
0
Given the name of an SQL table, I am looking to add quotes as necessary (with an loose definition of "necessary"). With SQL Server, the parts of the name should be wrapped in brackets ([ and ]), MySQL uses backticks (`). So, for example:
 
database.schema.table
database.schema.[table]
database.[schema].table
[database].[schema].table
 
should all be transformed to:
 
[database].[schema].[table]
 
What I have working; is capturing Wrapped and Unwrapped sections separately, wrapping the Unwrapped sections, and joining the sections back together. But it occurred to me that if I could Match only the Unwrapped sections, I could use Replace.
 
However, I have so far been unsuccessful in my attempts (otherwise I wouldn't be posting). Does anyone out there have an idea of how to do this? I'm thinking it may involve Balancing Groups, but I've never used them before so I'm finding them confusing.
 
This is not urgent. Big Grin | :-D
 

 
Edit: I must have been over-thinking it D'Oh! | :doh: . What I have now is (?<=^|\.)[^\[\]\.]+(?=$|\.)

Viewing all articles
Browse latest Browse all 224

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>