1

文字列に一重引用符が含まれている場合に保存の問題がある古いシステムを維持しています。

たとえば、これらは失敗します。

"update table set column2 = 'O'Connell', column3 = 'O'Riordon' where column1 = 1"
"insert into table (column1, column2, column3, column4, column5, column6, column7) values('O'Reilley','state, postcode','',1,2,'O'Riordon')". 

これまでのところ、この動作するvbscript正規表現を思いついた

([,=(]\s*'[^']*)'([^']*'\s*[,)\s])

ヘッダー[(| = | \ s |、]とトレーラー[、|)| \ s]を使用せずにvbscript正規表現を記述できますか?

ありがとう。

編集:削除するために投稿された正規表現を修正します| ヘッダーとトレーラーから。正規表現は次のように使用されます

regexp.replace("string","$1''$2")
4

1 に答える 1

1

私が考えることができる唯一の方法は、一重引用符を含む文字列に空白が含まれていない場合にのみ機能します。その場合は、検索できます

\B'([^'\s]*'[^'\s]*)'\B

説明:

\B        # Assert that there is no alphanumeric character before...
'         # the opening quote
(         # Match and capture...
 [^'\s]*  # Any number of non-quote/non-whitespace characters
 '        # One quote
 [^'\s]*  # Any number of non-quote/non-whitespace characters
)         # End of capture group 1
'         # Match the closing quote
\B        # Assert that there is no alphanumeric character afterwards
于 2012-10-03T04:54:14.503 に答える