-1

在Rails中不起作用?
statement= '<p>As he opened the door, Winston saw that he had left the diary open on the table. DOWN WITH BIG BROTHER was written in it, in letters you could almost <span style=\"text-decoration: underline;\">read</span> across the room.</p>\r\n<p>But everything was all right. A small, sad-looking woman was standing outside.</p>\r\n<p>'Oh, Comrade Smith,' she said, in a dull little voice, 'do you think you could come across and help me with our kitchen sink? The water isn't running away and ...'</p>\r\n<p>如何在rails中執行preg_match_all

result = statement.scan('/<span style="text-decoration: underline;">(.*)<\/span>/U') 
+0

的'statement'你給不是一個有效的字符串 – Sajin

回答

1

檢查這是否有所幫助。 如果

statement= "<p>As he opened the door, Winston saw that he had left the diary open on the table. DOWN WITH BIG BROTHER was written in it, in letters you could almost <span style='text-decoration: underline;'>read</span> across the room.</p>\r\n<p>But everything was all right. A small, sad-looking woman was standing outside.</p>\r\n<p>'Oh, Comrade Smith,' she said, in a dull little voice, 'do you think you could come across and help me with our kitchen sink? The water isn't running away and ...'</p>\r\n<p>".html_safe 

然後

result = statement.scan(/<span style='text-decoration: underline;'>.*<\/span>/) 
#=> ["<span style='text-decoration: underline;'>read</span>"] 
相關問題