我正从维基词典中检索一些数据。它们的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]]
是否可以选择=== Noun ===和====同义词之间的文字====? 例如,我想最终得到这个:
======================
可以在此处找到整个文本块:http://pastebin.com/raw.php?i=5ETx4ivB,可以在XML格式中找到API的结果:http://en.wiktionary.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles=developer
答案 0 :(得分:2)
你能试试吗
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===`
答案 1 :(得分:0)
使用indexOf()查找子字符串的位置,然后使用substr()获取您找到的两个位置之间的字符串。