2012-10-04 123 views
-7

我得到一個字符串到我的應用程序,它是修改字符串

[email protected]:[email protected]@17:[email protected]@[email protected]@17:[email protected]@17:[email protected]@$ 

我需要這個字符串轉換成類似

3-9-2012 17:[email protected] 17:[email protected]@[email protected] 17:[email protected] 17:[email protected]@$ 

請幫我一個解決方案,使我能得到期望的結果。 謝謝

+0

所有的答案之前:你不能,不能輕易至少。字符串是不可變的 - 你可以用你想要的屬性創建一個新的String對象 - 但不能修改字符串。 – amit

+0

你在做什麼...... –

+1

這裏需要應用的規則究竟是什麼?從這個例子中很難知道。 – Jesper

回答

0

找到年份參數後的@ charater。用「」字符替換它。就這樣。

3

str2 = str.replaceAll("(\\d{4})@(\\d)", "$1 $2")