gpt4 book ai didi

java - Matcher 会跳过第一场比赛吗?或者我做错了什么

转载 作者:行者123 更新时间:2023-12-02 01:24:34 26 4
gpt4 key购买 nike

我在 android 中的 Matcher 和 Pattern 方面遇到了一些奇怪的问题。它总是跳过第一场比赛,我不明白为什么。我是正则表达式的新手,该表达式在我在网上找到的测试人员上完美运行,但在我的测试应用程序中却不起作用我正在搜索的字符串“

<table id="intrebari" width="100%" cellpadding="3" cellspacing="3" border="0"><tbody><tr><td class="enunt" colspan="2">&nbsp;<b>1)</b>&nbsp;What vessels do COLREG rules 1983 apply to?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton1" id="buton11" value="0" wtx-context="0D1B1B61-E77D-43B5-AAF3-AF95F5E019C3"></td><td class="varianta" id="varianta11">To all vessels navigating in international waters<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton1" id="buton12" value="0" wtx-context="86B330AE-257A-4847-9E5E-518B28A291FD"></td><td class="varianta" id="varianta12">To all vessels navigating in roadsteads, straits and open seas<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton1" id="buton13" value="1" wtx-context="1C34F272-C776-401E-A367-0460D976CE21"></td><td class="varianta" id="varianta13">To all vessels upon the high seas and in all waters connected therewith<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_1" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(1)" wtx-context="B3A7B4BB-7D2A-4474-8C9C-1B3558BB87BC"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>2)</b>&nbsp;What does the word 'vessel' mean, according to the COLREG rules?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton2" id="buton21" value="0" wtx-context="76CB3796-696B-42EC-8172-5EB15FA6CEBC"></td><td class="varianta" id="varianta21">Any watercraft capable of floating on water without propelling machinery<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton2" id="buton22" value="1" wtx-context="C4726D1A-2B6E-4263-BDB6-BC8747728E9E"></td><td class="varianta" id="varianta22">Any watercraft including non-displacement craft and seaplanes used or capable of being used as a means of transportation on water<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton2" id="buton23" value="0" wtx-context="6F4568C8-31C7-41FF-8588-E52926FD0575"></td><td class="varianta" id="varianta23">Any floating object fitted with propelling machinery<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_2" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(2)" wtx-context="296F3D73-3F11-431E-9CB8-B4EF5D3BC026"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>3)</b>&nbsp;What does the word 'seaplane' mean?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton3" id="buton31" value="0" wtx-context="962489E9-00B1-444D-811D-3A1524C9493E"></td><td class="varianta" id="varianta31">Any aircraft designed to carry out hydrotechnical and/or hydrometeorological work<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton3" id="buton32" value="1" wtx-context="0B944352-F24B-42DD-8EF7-1709F0B77FD9"></td><td class="varianta" id="varianta32">Any aircraft designed to manoeuvre on the water<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton3" id="buton33" value="0" wtx-context="0ACDE372-5574-497F-8807-7B8ABB7D4E36"></td><td class="varianta" id="varianta33">Any aircraft being on the water for various reasons<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_3" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(3)" wtx-context="851C779C-D7A6-485D-85FB-19B46EE84D06"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>4)</b>&nbsp;What vessel may be considered as 'vessel restricted in her ability to manoeuvre'?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton4" id="buton41" value="1" wtx-context="756EE05D-A1B0-42B2-BEC1-12C594D35011"></td><td class="varianta" id="varianta41">A vessel engaged in replenishment or transferring persons, provisions or carge while underway<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton4" id="buton42" value="0" wtx-context="9C3426AB-1ED9-4BCD-AFAD-00905720345E"></td><td class="varianta" id="varianta42">A vessel lying to, on stormy weather<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton4" id="buton43" value="0" wtx-context="F5B11A33-D1AF-4048-867A-B04B800ABE0A"></td><td class="varianta" id="varianta43">A vessel with damages to the steering gear<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_4" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(4)" wtx-context="6BF5E721-62E5-4F67-8F0E-3029696AA119"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>5)</b>&nbsp;What vessel may be considered as 'vessel restricted in her ability to manoeuvre'?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton5" id="buton51" value="0" wtx-context="3A9A1A12-5B6E-461A-821C-E375C029C714"></td><td class="varianta" id="varianta51">A vessel engaged in towing, having the towing line less than 50 M in lenght<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton5" id="buton52" value="0" wtx-context="6FC9ABC3-F895-4EB4-97B7-11ED933BF294"></td><td class="varianta" id="varianta52">A pushing tug boat, underway, at night<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton5" id="buton53" value="1" wtx-context="D7B41021-E95A-46CF-ACC6-A7083A68DD6B"></td><td class="varianta" id="varianta53">A vessel engaged in towing operation such as severely restricts the towing vessel and her tow in their ability to deviate from their course<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_5" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(5)" wtx-context="72409550-315F-4592-96D3-BB1B56713D0E"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>6)</b>&nbsp;To what vessel is the term 'vessel restricted in her ability to manoeuvre' limited to?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton6" id="buton61" value="1" wtx-context="62B8D1C2-100E-4DA1-8378-0557ED497019"></td><td class="varianta" id="varianta61">The term 'vessel restricted in her ability to manoeuvre' will not be limited to the vessels quoted in the rules<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton6" id="buton62" value="0" wtx-context="56215EDA-A587-4D72-AFC0-283891A199B3"></td><td class="varianta" id="varianta62">It is limited to te vessels quoted in the rules<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton6" id="buton63" value="0" wtx-context="48407ACA-D9F2-4EBC-9692-C70A989D8720"></td><td class="varianta" id="varianta63">It is limited to the damaged vessels which are unable to keep out of the way of another vessel<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_6" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(6)" wtx-context="BC016A79-F89D-419A-BADD-6969B3C2F5CF"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>7)</b>&nbsp;What does the term 'vessel constrained by her draught' mean?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton7" id="buton71" value="0" wtx-context="E53F24D0-BBC5-476B-8A36-E071B71884E7"></td><td class="varianta" id="varianta71">A vessel which because of her draught and the existance of navigation obstructions in unable to deviate from her course<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton7" id="buton72" value="0" wtx-context="8450FFB0-30A0-496F-80F7-B5E4713B38DB"></td><td class="varianta" id="varianta72">A deep draught vesselbeing towed<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton7" id="buton73" value="1" wtx-context="AFEE346D-169A-4F94-AAEE-075C449BB563"></td><td class="varianta" id="varianta73">A power-driven vessel which because of her draght in relation to the avilable depth of water is severely restricted in her ability to deviate from her course<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_7" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(7)" wtx-context="C2C41294-4428-4742-9455-C0A299458567"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>8)</b>&nbsp;What does the term 'restricted visibility' mean?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton8" id="buton81" value="0" wtx-context="EBBB433B-5780-4CB5-A4CD-74B78BE11224"></td><td class="varianta" id="varianta81">Any condition in which visibility is reduced under 1,5 m<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton8" id="buton82" value="0" wtx-context="50A1F568-764A-4853-8E3E-A891FDBE82F8"></td><td class="varianta" id="varianta82">The condition in which the visibility is restricted by fog, rain or snow<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton8" id="buton83" value="1" wtx-context="CAA16AFC-2750-44A8-8BB2-C74F26AAD16D"></td><td class="varianta" id="varianta83">Any condition in which visibility is restricted by fog, mist, falling snow, heavy rainstorms, sandstorms or any other similar causes<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_8" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(8)" wtx-context="2F77F897-5786-4DBF-8D8C-964A70BE9D45"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>9)</b>&nbsp;Which are the factors taken into accouunt in determinating the 'safe speed'?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton9" id="buton91" value="0" wtx-context="56875C11-611B-476F-8463-798655CEEC14"></td><td class="varianta" id="varianta91">The vessel's length, nautical qualities of the vessel, the engine's power and the visibility<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton9" id="buton92" value="0" wtx-context="CE824CA1-4F09-42D0-8EC3-E2EDC522BE8C"></td><td class="varianta" id="varianta92">The crew's training, the navigation conditions and visibility<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton9" id="buton93" value="1" wtx-context="10E6E71B-5036-4F60-87E1-F8D9EAC486E8"></td><td class="varianta" id="varianta93">The visibility, the traffic density, the manoeuvrability of the vessel at night, the presence of background light, the state of wind and sea, the vessel's draught<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_9" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(9)" wtx-context="6C99FB2D-A229-4761-8D9C-93A56BB96761"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr><tr><td class="enunt" colspan="2">&nbsp;<b>10)</b>&nbsp;How shall an action to avoid collision be taken?<br><div class="spacer10"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton10" id="buton101" value="0" wtx-context="8D2299B0-89DC-4EF2-B664-4A9BBE64037F"></td><td class="varianta" id="varianta101">In ample time, with a succession of small alterations of course in order not to deviate from the vessel's course<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton10" id="buton102" value="1" wtx-context="9B6407DA-2F87-49D0-8713-D970CB948445"></td><td class="varianta" id="varianta102">Positively, in ample time and with due regard to the observance of good seamanship<div class="spacer"></div></td></tr><tr class="optiune"><td class="buton"><input type="radio" name="buton10" id="buton103" value="0" wtx-context="6C12441D-FD8A-46AD-8B06-95246BBC65EC"></td><td class="varianta" id="varianta103">Positively, with speed alterations to avoid risk of collision<div class="spacer"></div></td></tr><tr><td colspan="2" align="right"><input type="button" name="btn_10" class="arial_14" value="Arată răspunsul corect" onclick="verifica_intrebare(10)" wtx-context="D178B111-6CA1-49C5-9A5D-8DC1CBAEBE47"></td></tr><tr><td colspan="2" align="right"><div class="spacer20"></div></td></tr></tbody></table>
Pattern patternQ = Pattern.compile("<tr><td class=(.+?)</tr>"); 
Matcher matcherQ = patternQ.matcher(tabel);

boolean matchFound = matcherQ.find();

while (matcherQ.find()) {
System.out.print("Start index: " + matcherQ.start());
System.out.print(" End index: " + matcherQ.end());
System.out.println(" Found: " + matcherQ.group());
textView.append(matcherQ.group());
}

这是我缺少的东西吗?

最佳答案

它跳过第一个匹配的原因是每次调用 matcherQ.find() 都算作一次匹配,因此下一次调用将始终查找下一个匹配。

请注意,在第 4 行的 while 循环之前。您已经在第 3 行调用了 matcherQ.find() 来检查是否找到匹配项。

删除以下行,因为您在此代码 fragment 中没有使用它。

boolean matchFound = matcherQ.find();

关于java - Matcher 会跳过第一场比赛吗?或者我做错了什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57132918/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com