我在这里宽松地使用“后缀”来表示“前缀之后的任何子字符串”。
“前缀”在此表示单词的开始,其中单词的开始定义为空格或输入文本的第一个字符之后(对于第一个单词)。单词中间的“前缀”将被忽略。
例如,如果您输入的前缀是“ arm”,并且输入文本是“ Dumbledore的军队已为即将发生的世界末日大战充分武装”,则输出列表将包含(y,ed,ageddon)。
测试用例
假定区分大小写,字符串以空格结尾。输入将不会以空格开头。
删除重复项是可选的。
Input prefix: "1"
Input text:
"He1in aosl 1ll j21j 1lj2j 1lj2 1ll l1j2i"
Output: (ll, lj2j, lj2) - in any permutation
Input prefix: "frac"
Input text:
"fracking fractals fracted fractional currency fractionally fractioned into fractious fractostratic fractures causing quite a fracas"
Output: (king, tals, ted, tional, tionally, tioned, tious, tostratic, tures, as)
Input prefix: "href="https://www.astrotheme.com/astrology/"
Input text:
"(div style="padding: 0; background: url('https://www.astrotheme.com/images/site/arrondi_450_hd.png') no-repeat; text-align: left; font-weight: bold; width: 450px; height: 36px")
(div class="titreFiche" style="padding: 5px 0 0 6px")(a href="https://www.astrotheme.com/astrology/Nolwenn_Leroy" title="Nolwenn Leroy: Astrology, birth chart, horoscope and astrological portrait")Nolwenn Leroy(br /)
(/div)
(div style="text-align: right; border-left: 1px solid #b2c1e2; border-right: 1px solid #b2c1e2; width: 446px; padding: 1px 1px 0; background: #eff8ff")
(table style="width: 100%")(tr)(td style="width: 220px")
(div style="padding: 0; background: url('https://www.astrotheme.com/images/site/arrondi_450_hd.png') no-repeat; text-align: left; font-weight: bold; width: 450px; height: 36px")
(div class="titreFiche" style="padding: 5px 0 0 6px")(a href="https://www.astrotheme.com/astrology/Kim_Kardashian" title="Kim Kardashian: Astrology, birth chart, horoscope and astrological portrait")Kim Kardashian(br /)(span style="font-weight: normal; font-size: 11px")Display her detailed horoscope and birth chart(/span)(/a)(/div)
(/div)
(div style="padding: 0; background: url('https://www.astrotheme.com/images/site/arrondi_450_hd.png') no-repeat; text-align: left; font-weight: bold; width: 450px; height: 36px")
(div class="titreFiche" style="padding: 5px 0 0 6px")(a href="https://www.astrotheme.com/astrology/Julia_Roberts" title="Julia Roberts: Astrology, birth chart, horoscope and astrological portrait")Julia Roberts(br /)(span style="font-weight: normal; font-size: 11px")Display her detailed horoscope and birth chart(/span)(/a)(/div)
(td id="cfcXkw9aycuj35h" style="text-align: right")
(/div)"
Output: (Nolwenn_Leroy", Kim_Kardashian", Julia_Roberts")
获胜者,冠军
这是代码高尔夫球,因此最少的字节获胜。:)
只要您的代码可以解决诸如测试用例之类的任意问题,就可以以任何可行的方式接受输入。
https://www.astrotheme.com/astrology/
在前面加上时,怎么能成为前缀href="
?