CharSequence text = “自定义一个通配符”;
SpannableStringBuilder builder = new SpannableStringBuilder(text);
String rexgString = “自定义一个通配符”;
Pattern pattern = Pattern.compile(rexgString);
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
builder.setSpan(
new ImageSpan(this, R.drawable.ic_launcher), matcher.start(), matcher
.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
editText.setHint(builder1);
本文详细介绍了如何使用正则表达式在文本中查找特定模式,并通过设置文本高亮来突出显示匹配到的内容。通过实例演示了在Android应用中实现自定义通配符匹配的功能。

被折叠的 条评论
为什么被折叠?



