A
Alexandru Popescu
Hi!
Sorry for this `stupid=B4 question but it looks like i am suffering a men=
tal blockage:
if I have a string that contains single quote (f.e. "al'alamein") i would=
like to escape it with=20
another single quote (=3D> "al''alamein").
there are cases when these strings are already escaped according to the a=
bove rule, so those should=20
remain untouched
my `brainless=B4 attempt was:
but the above results in exactly the same strings. I would appreciate ver=
y much your help
=2E/alex
Sorry for this `stupid=B4 question but it looks like i am suffering a men=
tal blockage:
if I have a string that contains single quote (f.e. "al'alamein") i would=
like to escape it with=20
another single quote (=3D> "al''alamein").
there are cases when these strings are already escaped according to the a=
bove rule, so those should=20
remain untouched
my `brainless=B4 attempt was:
Code:
fixed_value =3D ""
wrong_value.each_with_index do |char, idx|
fixed_value << char
if ( (idx < wrong_value.size - 1) && (wrong_value[idx + 1] !=3D=
'\'') && (idx > 0) &&=20
(wrong_value[idx - 1] !=3D '\''))
fixed_value << '\''
end
end
but the above results in exactly the same strings. I would appreciate ver=
y much your help
=2E/alex