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
;
}
查看全文
相关阅读:
(ZOJ 3329) One Person Game (概率DP)
python爬虫之json数据处理
1034 Head of a Gang 图的遍历,map使用
1030 Travel Plan Dijkstra+dfs
vs C++ scanf 不安全
1021. Deepest Root DFS 求最长无环路径
1013. Battle Over Cities 用dfs计算联通分量
无法解析的外部符号
PAT DFS,BFS,Dijkstra 题号
1004 Counting Leaves 对于树的存储方式的回顾
原文地址:https://www.cnblogs.com/cnaspnet/p/1230882.html
最新文章
error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in
模型评价与损失函数
java进阶之阶段一
爬虫基础二
爬虫基础一
MysQl
python进阶之路三
Python进阶之路二
Python进阶之路一
canvas
热门文章
AJAX
博客搬家了
(HDU 4293) Groups (区间DP)
(POJ 3169) Layout(差分约束系统)
(POJ 2976)Dropping tests(01分数规划)
(HDu 4283)You Are the One(区间DP)
(HDU 5900)QSC and Master(区间DP)
(HDU 5115)Dire Wolf(区间DP)
(HDU 1698) Just a Hook(线段树)-附通用模板
(HDU 1695)GCD(容斥+莫比乌斯反演)
Copyright © 2011-2022 走看看