Is there a way in RegEx to say 'replace all of these except...'?

In the following text:

('The Riddler's False Notion','87312','1966-04-28T00:00:00Z',null),
('Scat, Darn Catwoman','87251','1966-03-30T00:00:00Z',null),
('Surf's Up! Joker's Under!','97151','1966-12-28T00:00:00Z',null),
('I'll Be a Mummy's Uncle!','97091','1966-09-28T00:00:00Z',null),
('The Purr-Fect Crime','97091','1966-09-28T00:00:00Z',null),
('Tut's Case Is Shut','97091','1966-09-28T00:00:00Z',null),
('The Devil's Fingers','17031','1967-10-05T00:00:00Z',null);

single-quote characters are used both as field delimiters and as apostrophes. 
So that the text can be inserted into a MySQL database, the apostrophes must be 
escaped (\') (Maybe some other characters as well.)

I wonder if I can use a Regular Expression to do the escaping. 

For example, the text:

('Surf's Up! Joker's Under!','97151','1966-12-28T00:00:00Z',null),

should be changed to:

('Surf\'s Up! Joker\'s Under!','97151','1966-12-28T00:00:00Z',null),

Now, I *could* try to think of every possible letter or letter combination that 
might follow an apostrophe:

's
't
're
etc.

but I might miss some and upon encountering the missed character possibility, 
the text would not be properly escaped.

So, I'm wondering, in RegEx, is there a way to specify change ' to \' in all 
instances EXCEPT where adjacent to a comma or parentheses? That is, I know that 
I need not escape the single-quote characters in these situations:
('
','
',

In those instances, the single-quote is a field delimiter and needed. All other 
instances are indeed apostrophes and need to be escaped.

Can RegEx specify that?



-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to