How to replace special charracters

From the form input I have some data which is inserted into database ,
and this data may have some special characters which can cause problems
in other parts of the system. Now before inserting into db, how can I
replace those characters with acceptable chars? Is there a standard way
to replace double quotes with single quotes, slash with hyphen etc.?

Thanks.

From the form input I have some data which is inserted into database ,
and this data may have some special characters which can cause problems
in other parts of the system. Now before inserting into db, how can I
replace those characters with acceptable chars? Is there a standard way
to replace double quotes with single quotes, slash with hyphen etc.?

Look into Tidy…

http://tidy.rubyforge.org/

-philip

If you are using it for db purpose, regarding the single quote issue,
you
can look at:

ActiveRecord::Base#sanitize_sql

Or a more flexible replacement, try ‘gsub’:

clean_string = “test”.gsub(/[regex]/, ‘[replaced character]’)

hello…

   if i have a string '12-34-56-78', how can i replace the '78' with

‘91’…pls…help…

thanks