2 回答

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊
在我看來(lái),我們可以做一件事。我希望你不介意無(wú)代碼答案。
通過(guò)字符 ' 拆分字符串并將其放入字符串?dāng)?shù)組中。例如字符串“h'e'll'o'”。變?yōu)?h , e , ll , o , .
忽略所有奇數(shù)索引。偶數(shù)索引中的字符串將是 ' 字符內(nèi)的字符串。上面的例子是 "e , o"
通過(guò)步驟 2 輸出字符串?dāng)?shù)組偶數(shù)索引或創(chuàng)建新數(shù)組。

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊
我想你正在尋找這樣的東西。
Pattern pattern = Pattern.compile("'[a-z0-9]+'");
private String function(final String input) {
final Matcher matcher = pattern.matcher(input);
final StringBuilder sb = new StringBuilder();
while (matcher.find()) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append(matcher.group());
}
return sb.toString();
}
但是,我不太確定您要應(yīng)用哪些規(guī)則以獲得預(yù)期結(jié)果。例如:"'''" => "'"?
添加回答
舉報(bào)