Page 1 of 1

Fixing bad quotes

Posted: Tue Apr 21, 2009 8:46 pm
by JBNY
Hello,

I am trying to find a regex to fix quotes in a document for example:

change

'Good. Then let's do it.'

to

"Good. Then let's do it."

I've tried the find expression
'((\\')|[^'(\\')])+'

and

'[^'\r\n]*'

but both catch the ' in let's as a quote as well.

Any ideas?

Thanks!
-Joe

Posted: Tue Apr 21, 2009 9:04 pm
by talleyrand
As soon as I post this, someone will correct me but I don't think this is a problem that regex is going to solve. And if it can, I don't think the current regex engine in TP will handle the solution.

The two big challenges you will encounter are multi-lines aren't supported and the parser is always greedy.

Posted: Wed Apr 22, 2009 11:14 am
by SteveH
I wonder if the SmartyPants Perl filter would be any use here.

This translates plain ASCII punctuation characters into “smart� typographic punctuation HTML entities. From there it would be a trivial search and replace to get back to the quotes you are after.

If it is only one document, and you can send it to me I would be happy to give this a try.