日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android 字符串换行符,\ n(换行符)删除Android

發布時間:2024/1/1 Android 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 字符串换行符,\ n(换行符)删除Android 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

調用Html.fromHtml(String)會將
正確翻譯為\ n。

String html = "06:00 Vesti
07:15 Something Else
09:10 Movie ...
15:45 Something..";

String str = Html.fromHtml(html).toString();

String[] arr = str.split("\n");然后,只需將它拆分為行 - 不需要regexp(在第一種情況下你不應該使用它來解析HTML)。

編輯 b>:將所有內容變成一堆Dates

// Used to find the HH:mm, in case the input is wonky

Pattern p = Pattern.compile("([0-2][0-9]:[0-5][0-9])");

SimpleDateFormat fmt = new SimpleDateFormat("HH:mm");

SortedMap programs = new TreeMap();

for (String row : arr) {

Matcher m = p.matcher(row);

if (m.find()) {

// We found a time in this row

ParsePosition pp = new ParsePosition(m.start(0));

Date when = fmt.parse(row, pp);

String title = row.substring(pp.getIndex()).trim();

programs.put(when, title);

}

}

// Now programs contain the sorted list of programs. Unfortunately, since

// SimpleDateFormat is stupid, they're all placed back in 1970 :-D.

// This would give you an ordered printout of all programs *AFTER* 08:00

Date filter = fmt.parse("08:00");

SortedMap after0800 = programs.tailMap(filter);

// Since this is a SortedMap, after0800.values() will return the program names in order.

// You can also iterate over each entry like so:

for (Map.Entry program : after0800.entrySet()) {

// You can use the SimpleDateFormat to pretty-print the HH:mm again.

System.out.println("When:" + fmt.format(program.getKey()));

System.out.println("Title:" + program.getValue());

}

總結

以上是生活随笔為你收集整理的android 字符串换行符,\ n(换行符)删除Android的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。