public static String replaceDoubleSingleQuotes ( String value ) { int idx = value . indexOf ( "''" ) ; if ( idx == - 1 ) return value ; int len = value . length ( ) ; int pos = 0 ; StringBuilder sb = new StringBuilder ( len ) ; while ( idx != - 1 ) { if ( idx > pos ) { sb . append ( value . substring ( pos , idx ) ) ; pos += ( idx - pos ) ; } sb . append ( "'" ) ; pos += 2 ; idx = value . indexOf ( "''" , pos ) ; } if ( pos < len ) sb . append ( value . substring ( pos , len ) ) ; return sb . toString ( ) ; }
Replace double single quotes in the target string