Dominik,

> I have a list of states and want to xtract only
> the names without "(12345)"

    If you're looking for states without numbers, just avoid any state with
a numeric digit:

states_array.each { |state| puts state if state !~ /[0-9]/ }


> And please show me how I can easily substitute a
> single quotation mark by a  backslash and single
> qotation mark to write it safely into a
> database.....
> Finally I got this one, but it's damn ugly:
> .gsub("'") { "\\'" }
> Because \' is a special character combination
> and I don't know how to escape it... \\' doesn't
> work

    Unfortunately, not only are double backslashes converted to a single
backslash when the string is parsed, but an additional substitution pass is
made by sub() which also converts double backslashes to single backslashes,
as well as interpreting: (\1), (\2), (\3), etc., (\&), (\+), (\`), and (\').
So you need to pass sub() the string (\\'), which means that the literal
must be "\\\\'" (or even worse, '\\\\\''):

my_string.gsub("'","\\\\'")

    I hope this helps!

    - Warren Brown