开发者

PostgreSql + Escape Enter Key from Query Statement ie Enter Key pressed betweent the data

Suppose we have a textarea in which开发者_Python百科 we put example string. Textbox contain :

Earth is revolving around the Sun.

But at the time of saving, I just pressed a enter key after "the sun". Now the statements in texbox ::

Earth is revolving around
 the Sun.

Now I am trying to fetch the data but unable just because of that enter key pressed by me in between the string. So please suggest me how to escape this enter key ??

Thanks in Advance !!!


Enter key is pressed within the text area then \r\n entered in db. So by replacing this value we can escape it by an other alphabet or symbol.


You just need delete all enter key in before_save method

class user
  before_save :no_enter

  def no_enter
    self.content = self.content.gsub('\n', '')
  end
end


Look up Perl compatible regular expressions in PostgreSQL. You can then use this to update or select your data as approprite.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜