我試圖解析以下格式的字符串中的Java:解析字符串輸入的自由文本
Number-Action-Msg, Number-Action-Msg, Number-Action-Msg, Number-Action-Msg, ...
例如
"512-WARN-Cannot update the name.,615-PREVENT-The app is currently down, please try again later.,736-PREVENT-Testing,"
我想獲得與數組以下條目:
512-WARN-Cannot update the name.
615-PREVENT-The app is currently down, please try again later.
736-PREVENT-Testing
問題是,該消息是用戶輸入,所以我不能依靠只是逗號來分裂你字符串。這些行爲將始終是WARN或PREVENT。什麼是完成這個解析的最好方法?謝謝!
@pczeus as told me .... *我不能只依賴逗號來分割字符串*所以......用逗號分隔...... :) –