4

Wiktionary API からデータを取得しています。彼らの API は、html 属性や xml 属性を持たないテキスト ブロック全体を解析します。

テキストの例:

===Etymology===
{{-er|develop}}

===Pronunciation===
* {{a|UK}} {{IPA|/dɪˈvɛləpə(ɹ)/}}
* {{a|US}} {{IPA|/dɪˈvɛləpɚ/}}

===Noun===
{{en-noun}}

# A person or entity engaged in the [[creation]] or [[improvement]] of certain classes of products.
# A [[real estate]] developer; a person or company who prepares a parcel of land for sale, or creates structures on that land.
# A [[film]] developer; a person who uses [[chemical]]s to create [[photograph]]s from photograph negatives.
# A [[liquid]] used in the chemical processing of traditional photos.
# A [[software]] developer; a person or company who creates or modifies [[computer]] software.

====Synonyms====
* {{sense|person or company who writes computer software}} [[programmer]]

====Related terms====
* [[develop]]
* [[development]]
* [[developmental]]

===名詞=== と ====類義語==== の間のテキストを選択することは可能ですか? たとえば、私はこれで終わりたいです:

  • 特定のクラスの製品の作成または改善に携わる個人または団体。
  • 不動産開発業者; 販売用の土地区画を準備するか、その土地に構造物を作成する人または会社。
  • フィルム開発者; 写真のネガから[[写真]]を作成するために[[化学]]を使用する人。
  • 従来の写真の化学処理に使用される液体。
  • ======================

    テキストのブロック全体はhttp://pastebin.com/raw.php?i=5ETx4ivBにあり、API からの結果は XML 形式でここにあります: http://en.wiktionary.org/ w/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles=developer

    4

    2 に答える 2

    1

    やってみませんか

    var start  = str.indexOf('===Noun==='), end = str.indexOf('====Synonyms====');
    var text = str.substring(start + 11, end) // +11 since `indexof` gives the start index and you need to exclude `===Noun===`
    
    于 2013-03-01T03:07:30.667 に答える
    0

    indexOf() を使用して部分文字列の位置を見つけてから、substr() を使用して、見つけた 2 つの位置の間の文字列を取得します。

    于 2013-03-01T03:02:58.970 に答える