zoukankan
html css js c++ java
搜索关键字变色及高亮显示
1.替换关键字,对字体变色。
public
static
string
ReplaceRed(
string
strtitle,
string
redkey)
{
if
(redkey
==
""
||
redkey
==
null
)
{
return
strtitle;
}
else
strtitle
=
strtitle.Replace(redkey,
"
<font color='#ff0000'>
"
+
redkey
+
"
</font>
"
);
return
strtitle;
}
2.用正则,CSS背景变色。
protected
string
HighlightText(
string
inputText,
string
searchWord)
{
System.Text.RegularExpressions.Regex expression
=
new
System.Text.RegularExpressions.Regex(searchWord.Replace(
"
"
,
"
|
"
), System.Text.RegularExpressions.RegexOptions.IgnoreCase);
return
expression.Replace(inputText,
new
System.Text.RegularExpressions.MatchEvaluator(ReplaceKeywords));
}
public
string
ReplaceKeywords(System.Text.RegularExpressions.Match m)
{
return
"
<span class='highlightTxtSearch'>
"
+
m.Value
+
"
</span>
"
;
}
CSS:
.highlightTxtSearch
{
}
{
background-color
:
Yellow
;
}
查看全文
相关阅读:
[转] MapReduce详解
[转] 自然语言处理全家福:纵览当前NLP中的任务、数据、模型与论文
[转] 一文读懂BERT中的WordPiece
[转] 文本分类——GLUE数据集介绍
[转] Transformer详解
[python] 转json好用的工具mark
[转] 深度学习中的注意力机制
[转] Python之time模块的时间戳、时间字符串格式化与转换
日期相关
airflow的定时任务
原文地址:https://www.cnblogs.com/cnaspnet/p/1230882.html
最新文章
oracle 截取字符(substr),检索字符位置(instr)
superset docker 部署
nginx入门教程
docker安装gitlab-ce
k8s编排
ubuntu k8s 命令补全
helm install
linux ecrypt decrypt
k8s aliyun
k8s framework
热门文章
linux命令之删除出某个文件之外的所有文件
Python3 configparse模块(配置)转载https://www.cnblogs.com/bert227/p/9326313.html
Python多线程的初步的认识(转载自https://www.cnblogs.com/yeayee/p/4952022.html)
Python Tkinter 会话窗口(转载自https://blog.csdn.net/bnanoou/article/details/38515083)
tkinter.ttk — Tk themed widgets
tkinter怎么使Toplevel保持在主窗口的上面
Tkinter Toplevel
python-pip升级报错- AttributeError: 'NoneType' object has no attribute 'bytes'
python ttk Treeview的插入、清空、各种点击事件、获取条目值、标题单击排序
Python GUI之tkinter布局管理
Copyright © 2011-2022 走看看