Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个跨区字符串,其中包含一些粗体文本以及常规文本。我需要用简单的常规字符(如“x”或“_”)替换所有粗体文本,然后将结果保存到字符串中。我注意到没有像字符串那样的跨越字符串的替换函数;这是可能吗?
谢谢!
您可以Spanned使用以下方法获取文本值:
Spanned
String text = Html.toHtml(spanned);
然后,您只需使用 replace() 方法将 < b > 和 < /b > 标记之间的文本替换为“x”或“_”字符。