开发者

Normalizing User Input - to do a text match in Ruby

I'm working to allow a user to input text in a textarea. T开发者_如何学Cheir input saves to the DB like so:

--\r\nHello World\r\nI see stars\r\n\r\nVisit My Website: www.website.com

Problem is I'm trying to find that inside of a parsed email. While it looks the same when rendered. It's being stored differently and I don't have control over that. The text looks like:

--\nHello World\nI see stars\n\nVisit My Website: www.website.com\n\n

While these both render the same, they are stored differently which causes this to fail:

email.sub(useinput, '').strip

Thoughts? Ideas? Thanks


text1 = "--\r\nHello World\r\nI see stars\r\n\r\nVisit My Website: www.website.com"
text1_modified = text1.gsub("\r\n", "\n")
text2 = "--\nHello World\nI see stars\n\nVisit My Website: www.website.com\n\n"
text2.sub(text1_modified, '').strip
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜