我正在查询维基词典API,我需要匹配" === Noun ==="包括之后的文本,直到" ====翻译===="开始。实际的JSON对象更大,我需要多次匹配,包括" ===动词==="在Regexr.com上,我设法让它匹配但不在我的javascript中:
var regex = /(===Verb===|===Noun===|===Adjective===|===Adverb===).*?====/g;
console.log(jsondata.match(regex));
console.log(regex.test(jsondata));
非常感谢任何帮助!
==English== ===Pronunciation=== * , * , * * * * ===Noun=== # [[feces|Feces]]. ====Synonyms==== * [[BM]] * [[doo-doo]] * [[poo]] * [[poop]] ===Interjection=== # #* '''1995''', Phil Farrand, ''The Nitpicker's Guide for Next Generation Trekkers: Volume 2'' #*: (Ever feel like you've just entered... The Twilight Zone? '''Doo''', doo, doo, doo, doo, doo....) #* '''2006''', Steve Taylor, ''A to X of Alternative Music'' (page 272) #*: the bloke who sang about coloured girls going ''''doo''' de doo de doo doo d'de doo de doo de doo' had once had this thing with the guy who produced the debut albums by the Stooges and Patti Smith. ====Related terms==== * [[doo-wop]] ---- ==Gooniyandi== ===Noun=== # [[cave]] ---- ==Manx== ===Etymology=== From , from , from . ===Adjective=== # [[black]] # [[inky]] ====Synonyms==== * ====Derived terms==== * ===Noun=== # [[ink]] ====Derived terms==== ===Verb=== # to [[ink]] ===Mutation=== [[Category:gv:Colors]] ---- [[Category:Navajo terms with audio links]] ==Navajo== ===Pronunciation=== * ===Particle=== # Part of the [[negative]] correlative: #: '''''doo''' ... da'': #:: # With a nominalizer, forms a negative noun phrase: #: #: #: # Pairing '''doo''' with a verb + [[-góó]] forms a negative conditional: #: ====Derived terms==== ===Pronunciation=== * ===Verb=== # ''it will be'' (abbreviated form of [[dooleeł]]) # paired with [[ńtʼééʼ]], it forms a conditional: #: #: ====See also==== * * ---- ==Portuguese== ===Verb=== # # ---- ==Rohingya== ===Noun=== # [[knife]] ---- ==Scots== ===Etymology=== From (compare woman's [[given name]] ); akin to Old High German , Icelandic , ''[[Dúfa]]'' "[[Dove]]" (woman's [[first name]]), Swedish , Danish and Norwegian . ===Pronunciation=== * ===Noun=== # [[dove]] (bird of the pigeon family, [[Columbidae]]) ====Derived terms==== * [[King of the Doos]] [[es:doo]] [[fr:doo]] [[lt:doo]] [[mg:doo]] [[pl:doo]] [[ru:doo]] [[fi:doo]] [[tr:doo]]
答案 0 :(得分:0)
你没有捕捉到字符串的正确部分
/(?:===Verb===|===Noun===|===Adjective===|===Adverb===)(.*?)====Translations====/g
答案 1 :(得分:0)
这似乎适合你的正则表达式
var regex = /(===Verb===|===Noun===|===Adjective===|===Adverb===).*?====/g;
答案 2 :(得分:0)
确保您的json已正确转义。
在我的示例中,我将单词ōʹvə-flō'
,ō'və-flōʹ
,ōʹvər-flō'
和ō'vər-flōʹ
转发给ōʹvə-flō\'
,ō\'və-flōʹ
,{{分别为1}}和ōʹvər-flō\'
:
ō\'vər-flōʹ