我在查詢wiktionary API,並且需要匹配「===名詞===」,包括之後的文本,直到「==== Translations ====」開始。實際的JSON對象比較大,我需要匹配幾次,包括「===動詞===」等。在Regexr.com上,我設法讓它匹配,但不是在我的JavaScript:正則表達式不匹配 - 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]]
究竟這是怎麼不工作? –
你至少可以嘗試格式化一些問題,讓人們不會暈頭轉向。 – Craicerjack
更好地使用一些XML解析器,請參閱http://stackoverflow.com/q/7949752/1682509 – Reeno