比方說,我有一個字符串ReplaceFirst正則表達式
String link = "www.thisisalink.com/[email protected]@&[email protected]@&[email protected]@&[email protected]@";
那麼我可以用
link = replaceFirst("(.+)[email protected]\\[email protected]", "");
爲了讓
link = "www.thisisalink.com/&[email protected]@&[email protected]@&[email protected]@";
但我想循環雖然字符串,獲取已被替換的內容並將其保存到其他位置,如鏈接列表或數組...結果將爲:
String[] result = ["[email protected]@", "[email protected]@", "[email protected]@", "[email protected]@"];
String link = "www.thisisalink.com/&&&";
但我該怎麼做?我試着循環使用
while (link.matches("(.+)[email protected]\\[email protected]")){}
哪個沒有用。
謝謝:)多數民衆贊成在很好。 –