So, I believe people need a bit more information.
Do you have a string that has extra \n's that you want to get rid of ?
Or, are you trying to put a sql statement in source code with extra \n's so that it is more readable to you ???
Here's examples of both:
# first fill a string with data including \n chars.
sql = <<END_OF_SQL
select
*
from
LIB.ACCOUNTs accounts,
LIB.SSNS ssns,
LIB.PLANS plans
where
accounts.FOO_KEY = ssns.BAR_KEY
and plan.BAZ_KEY = ssns.BAR_KEY
and ssns.DEPCD = ''
and ... ETC ETC ETC
*
from
LIB.ACCOUNTs accounts,
LIB.SSNS ssns,
LIB.PLANS plans
where
accounts.FOO_KEY = ssns.BAR_KEY
and plan.BAZ_KEY = ssns.BAR_KEY
and ssns.DEPCD = ''
and ... ETC ETC ETC
END_OF_SQL
# now clean out the \n chars
formatted_sql = sql.gsub( /\n/, '' )
On 11/28/05, Sean Gallagher <[EMAIL PROTECTED]> wrote:
What about using a "here document"?
irb(main):013:0> foo=<<HERE
irb(main):014:0" select *
irb(main):015:0" from foo
irb(main):016:0" where someval='bar'
irb(main):017:0" HERE
=> "select *\nfrom foo\nwhere someval='bar'\n"
irb(main):018:0> print(foo)
select *
from foo
where someval='bar'
=> nil
irb(main):019:0>
-sean
Hope that helps.
j.
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
