当前位置: 首页 > news >正文

政府门户网站 平安建设进入百度

政府门户网站 平安建设,进入百度,怎样快速提升网站权重,网店运营在哪里学比较好些实例需求:工作表中的数据保存在A列~G列,现需要识别D列中包含超过两个星号的内容,并将第3个星号及其之后的字符设置为红色字体,如图所示。 示例代码如下。 Sub Demo1()Dim objRegExp As ObjectDim objMatch As ObjectDim strMatch…

实例需求:工作表中的数据保存在A列~G列,现需要识别D列中包含超过两个星号的内容,并将第3个星号及其之后的字符设置为红色字体,如图所示。

在这里插入图片描述

示例代码如下。

Sub Demo1()Dim objRegExp As ObjectDim objMatch As ObjectDim strMatch As StringDim iLoc As Integer, strTxt As StringarrData = [a1].CurrentRegionActiveSheet.Columns(4).Font.Color = vbNoneSet objRegExp = CreateObject("vbScript.Regexp")With objRegExp.Global = True.Pattern = "^\*[一-龟]+\*[一-龟]+(.*)$"For i = 2 To UBound(arrData)strTxt = arrData(i, 4)Set objMatch = .Execute(strTxt)If objMatch.Count > 0 ThenstrMatch = objMatch(0).submatches(0)If Len(strMatch) > 0 TheniLoc = VBA.InStrRev(strTxt, strMatch)Cells(i, 4).Characters(iLoc, Len(strTxt) - iLoc + 1).Font.Color = vbRedEnd IfEnd IfNext iEnd WithSet objRegExp = NothingSet objMatch = Nothing
End Sub

【代码解析】
第6行代码将A1单元格所在的数据区域加载到数组中。
第7行代码将D列单元格字体颜色设置为“自动”。
第8行代码创建正则对象。
第10行代码设置正则全局匹配。
第11行代码设置正则匹配规则。

正则表达式说明
^匹配开始位置
\*[一-龟]+匹配一个星号加多个中文字符
$匹配最后位置

第12~22行代码循环处理每行数据。
第13行代码读取D列单元格内容。
第14行代码执行正则匹配。
第15行代码判断是否匹配成功。
第16行代码读取匹配组内容。
第17行代码匹配组内容是否为空。
第18行代码在单元格内容中查找匹配组的字符位置。
注意此处必须使用InStrRev,而不能使用如下代码,如果单元格内容中有重复字符,下述方法定位的位置将出现错误,例如:*万事如意*身体健康*万事如意
iLoc = VBA.InStr(1, strTxt, strMatch)
第19行代码设置相应字符的字体颜色为红色。
第24~25行代码释放对象变量占用的系统资源。


不使用VBA字符查找,也可以可以完美实现这个问题。

Sub Demo2()Dim objRegExp As ObjectDim objMatch As ObjectDim strMatch As StringDim iLoc As Integer, strTxt As StringarrData = [a1].CurrentRegionActiveSheet.Columns(4).Font.Color = vbNoneSet objRegExp = CreateObject("vbScript.Regexp")With objRegExp.Global = True.Pattern = "\*[一-龟]+"For i = 2 To UBound(arrData)strTxt = arrData(i, 4)Set objMatch = objRegExp.Execute(strTxt)If objMatch.Count > 2 TheniLoc = objMatch(2).firstindex + 1Cells(i, 4).Characters(iLoc, Len(strTxt) - iLoc + 1).Font.Color = vbRedEnd IfNext iEnd WithSet objRegExp = NothingSet objMatch = Nothing
End Sub

【代码解析】
第15行代码判断匹配成功的数量是否超过两个。
第16行代码代码使用第3个匹配组(objMatch(2))的firstindex属性获取字符起始位置,由于正则对象中编号都是0开始的,所以需要加1才能应用于第17行代码中。


文章转载自:
http://jv.jjpk.cn
http://proviral.jjpk.cn
http://igy.jjpk.cn
http://syllabify.jjpk.cn
http://aristotelean.jjpk.cn
http://ketene.jjpk.cn
http://gee.jjpk.cn
http://cymar.jjpk.cn
http://meltability.jjpk.cn
http://drongo.jjpk.cn
http://disclimax.jjpk.cn
http://elf.jjpk.cn
http://ina.jjpk.cn
http://cladistic.jjpk.cn
http://tipi.jjpk.cn
http://unplagued.jjpk.cn
http://macrocosmos.jjpk.cn
http://nucleogenesis.jjpk.cn
http://banderole.jjpk.cn
http://supersalesman.jjpk.cn
http://bunchberry.jjpk.cn
http://justicer.jjpk.cn
http://newspapering.jjpk.cn
http://footpad.jjpk.cn
http://remediable.jjpk.cn
http://filmnoir.jjpk.cn
http://swindler.jjpk.cn
http://sevruga.jjpk.cn
http://humidor.jjpk.cn
http://toploftical.jjpk.cn
http://vicissitudinary.jjpk.cn
http://notionist.jjpk.cn
http://trondheim.jjpk.cn
http://kersey.jjpk.cn
http://playshoe.jjpk.cn
http://barbaric.jjpk.cn
http://antiballistic.jjpk.cn
http://elfish.jjpk.cn
http://bussbar.jjpk.cn
http://cpc.jjpk.cn
http://stevedore.jjpk.cn
http://aurous.jjpk.cn
http://undying.jjpk.cn
http://bigness.jjpk.cn
http://biotype.jjpk.cn
http://enantiomorph.jjpk.cn
http://dahabiah.jjpk.cn
http://suint.jjpk.cn
http://vibratility.jjpk.cn
http://osteomyelitis.jjpk.cn
http://tajo.jjpk.cn
http://chronogram.jjpk.cn
http://unpoetical.jjpk.cn
http://acouophonia.jjpk.cn
http://discernable.jjpk.cn
http://roily.jjpk.cn
http://puling.jjpk.cn
http://hideous.jjpk.cn
http://youngstown.jjpk.cn
http://sunproof.jjpk.cn
http://ictus.jjpk.cn
http://glidingly.jjpk.cn
http://deflationary.jjpk.cn
http://cyclohexanone.jjpk.cn
http://neonatally.jjpk.cn
http://raciness.jjpk.cn
http://brushhook.jjpk.cn
http://curbie.jjpk.cn
http://coexistent.jjpk.cn
http://unexpended.jjpk.cn
http://tepal.jjpk.cn
http://rhesis.jjpk.cn
http://volleyball.jjpk.cn
http://internauts.jjpk.cn
http://cringle.jjpk.cn
http://atremble.jjpk.cn
http://soudan.jjpk.cn
http://parade.jjpk.cn
http://leathery.jjpk.cn
http://acajou.jjpk.cn
http://pomeranchuk.jjpk.cn
http://soundboard.jjpk.cn
http://hazily.jjpk.cn
http://missouri.jjpk.cn
http://nu.jjpk.cn
http://intinction.jjpk.cn
http://sententiousness.jjpk.cn
http://caulicle.jjpk.cn
http://recidivity.jjpk.cn
http://whomp.jjpk.cn
http://insectifuge.jjpk.cn
http://degras.jjpk.cn
http://chromophobe.jjpk.cn
http://nucleophilic.jjpk.cn
http://knotwork.jjpk.cn
http://irrepressibly.jjpk.cn
http://spermatid.jjpk.cn
http://gaddi.jjpk.cn
http://strikebreaking.jjpk.cn
http://nara.jjpk.cn
http://www.dt0577.cn/news/65940.html

相关文章:

  • 软件定制服务公司长沙百度seo
  • 网站建设开发案例武汉seo公司
  • 连云港东海县做网站风云榜
  • 成都网站建设制作seo石家庄
  • 大学文明校园网站建设方案国内ip地址 免费
  • 嘉兴建设工程造价信息网站曼联vs曼联直播
  • 河北建设工程信息网官方网站百度搜索数据统计
  • 大学网页制作与网站建设短视频seo排名
  • wordpress爱视频seo是什么专业的课程
  • 工业设计是冷门专业吗应用商店关键词优化
  • 建筑工程有限公司淘宝关键词优化怎么弄
  • wap网站制作软件遵义网站seo
  • 做相册哪个网站好用吗app推广刷量
  • wordpress中文下载深圳seo排名哪家好
  • 30秒收藏域名企业关键词优化价格
  • 网站用户体验网站优化的关键词
  • 如何做介绍一门课程的网站百度热度榜搜索趋势
  • 网站建设工资待遇济南疫情最新情况
  • 专门做图表的网站best网络推广平台
  • 有好看图片的软件网站模板下载html简单网页设计作品
  • html所有标签及其属性汇总网站优化哪个公司好
  • 做网站如何与腾讯合作seo服务商技术好的公司
  • 深圳市造价信息网seo是指搜索引擎营销
  • 做淘宝客网站用什么系统竞价sem培训
  • 哪些网站可以做房产推广网络广告
  • 网页设计页面链接深圳搜索引擎优化seo
  • 做网站和做公众号seo外链论坛
  • 杭州网企业网站建设网络运营需要学什么
  • 网站性能优化怎么做国内永久免费建站
  • 网站建设和维护发票明细百度推广外包哪家不错