私のアプリケーションでは、テキスト記事から最初の段落を抽出しようとしています。これどうやってするの?
質問する
548 次
2 に答える
1
これは、次の方法で行うことができます。
test = <<PARAGRAPH
I've actually been using the latest version of JAWS (the popular Windows screen reader software for blind people) recently, as part of my work on HTML5. From a usability point of view it is possibly the worst software I have ever used. I'm still horrified at how bad the accessibility situation is.
For example, JAWS will happily take the last sentence of a paragraph, and the first sentence of the next paragraph, and run them into each other as one sentence, if there's no full stop at the end of the first paragraph. If you really want to make your Web pages more readable to blind users, forget longdesc or even alt, or even markup of any kind, just make sure you're using full punctuation! And that's just one example.
'
PARAGRAPH
puts test[/(.*)/] # This will print the first paragraph.
于 2013-02-21T17:35:21.710 に答える
0
1 つの方法:
>> str="<p>sadsda</p>"
=> "<p>sadsda</p>"
>> str.scan(/<p>(.*)<\/p>/)
=> [["sadsda"]]
>> str.scan(/<p>(.*)<\/p>/)[0]
=> ["sadsda"]
于 2013-02-21T16:50:42.587 に答える