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

网上哪个网站教做西点千度搜索引擎

网上哪个网站教做西点,千度搜索引擎,复兴网站制作,有哪些外贸公司网站做的比较好1. 数据验证 正则表达可用于验证文本是否满足某种给定的模式。 正则表达式也是一种语言,因此在使用之前必须先对其进行编译,并将编译结果保存在一个Regexp类型的变量里。以下两个函数即返回该变量的指针。 re, err : regexp.Compile("^[a-zA-Z0-…

1. 数据验证

正则表达可用于验证文本是否满足某种给定的模式。

正则表达式也是一种语言,因此在使用之前必须先对其进行编译,并将编译结果保存在一个Regexp类型的变量里。以下两个函数即返回该变量的指针。

  • re, err := regexp.Compile("^[a-zA-Z0-9]{5,12}$") 
    • 在正则表达式未通过编译时返回错误
  • re := regexp.MustCompile("^[a-zA-Z0-9]{5,12}$") 
    • 在正则表达式未通过编译时引发恐慌

Regexp类型的MatchString方法根据其参数字符串与正则表达式是否匹配返回true或者false。当通过Regexp类型变量使用MatchString方法时,仅需提高1个被验证字符串即可,因为正则表达式已提前编译并保存在调用对象内部。

  • fmt.Println(username, "->", re.MatchString(username))

正则表达式已提前编译并保存在re内部,故该方法比regexp.MatchString函数少了一个参数。

// 数据验证
// 正则表达可用于验证文本是否满足某种给定的模式
// 正则表达式 = regexp.MustCompile(模式) 
// 验证通过 = 正则表达式.MatchString(被验证文本) 
package main
import ("fmt""regexp"
)
func main() {usernames := [...]string{"slimshady99","!asdf£33£3","roger","iamthebestuseofthisappevaaaar",}re := regexp.MustCompile("^[a-zA-Z0-9]{5,12}$")for _, username := range usernames {fmt.Println(username, "->",re.MatchString(username))}
}
// 打印输出:slimshady99 -> true!asdf£33£3 -> false	// !roger -> trueiamthebestuseofthisappevaaaar -> false 	// 字符数超过12

 2. 数据变换

正则表达可对文本中符合特定模式的内容进行替换。

Regexp类型的ReplaceAllString方法接受两个参数,第一个参数为被替换文本,第二个参数为替换文本。该方法将被替换文本中与调用变量中的正则表达式匹配的部分替换为替换文本。

  • an := regexp.MustCompile("[[:^alnum:]]")
    • 匹配由非(^)英语字母(alphabet)和数字(number)组成的字符集中的任意一个字符。
    • [:^ASCII类名:]      匹配“ASCII类”外的一个字符,“ASCII类”见附录的说明。
  • newUsername = an.ReplaceAllString(newUsername, "x")
    • 将newUsername中所有既非英语字母亦非数字的字符替换为"x"
    • 例如:!asdf£33£3 -> xasdfx33x3

先根据正则表达式对数据进行评估,检查其中是否含有非法字符。如果含有非法字符,再根据正则表达式将其替换为合法字符——数据清洗管道。

// 数据变换
// 正则表达可对文本中符合特定模式的内容进行替换
// 正则表达式 = regexp.MustCompile(模式) 
// 正则表达式.ReplaceAllString(被替换文本, 替换文本) 
package mainimport ("fmt""regexp"
)func main() {usernames := [...]string{"slimshady99","!asdf£33£3","roger","iamthebestuseofthisappevaaaar",}re := regexp.MustCompile(	//	定义正则表达1"^[a-zA-Z0-9]{5,12}$")an := regexp.MustCompile("[[:^alnum:]]")//定义用于数据替换的正则表达式2for _, username := range usernames {newUsername := usernameif len(newUsername) > 12 {	// 首先判断用户名是否符合长度要求newUsername = newUsername[:12]	// 不符合的直接截断}if !re.MatchString(newUsername) { // 检查用户名是否符合正则表达式1要求newUsername = an.ReplaceAllString(	// 将所有非法字符替换为xnewUsername, "x")}fmt.Println(username, "->", newUsername)}
}
// 打印输出:
slimshady99 -> slimshady99
!asdf£33£3 -> xasdfx33x3
roger -> roger
iamthebestuseofthisappevaaaar -> iamthebestus //截断

 

 


文章转载自:
http://transferee.c7507.cn
http://buffalofish.c7507.cn
http://taster.c7507.cn
http://therapeutic.c7507.cn
http://labradorite.c7507.cn
http://diopter.c7507.cn
http://pulsar.c7507.cn
http://southernization.c7507.cn
http://pseudomemory.c7507.cn
http://snapback.c7507.cn
http://unillusioned.c7507.cn
http://marquee.c7507.cn
http://smattering.c7507.cn
http://erythropsia.c7507.cn
http://beerless.c7507.cn
http://bezzant.c7507.cn
http://perspicuous.c7507.cn
http://cyanoguanidine.c7507.cn
http://kerulen.c7507.cn
http://favoured.c7507.cn
http://carhop.c7507.cn
http://photocurrent.c7507.cn
http://disoriented.c7507.cn
http://melomania.c7507.cn
http://pyranometer.c7507.cn
http://nebenkern.c7507.cn
http://mauretanian.c7507.cn
http://swap.c7507.cn
http://parental.c7507.cn
http://murdabad.c7507.cn
http://osa.c7507.cn
http://pandanaceous.c7507.cn
http://sendout.c7507.cn
http://lipped.c7507.cn
http://tactual.c7507.cn
http://centralization.c7507.cn
http://sphagna.c7507.cn
http://consociation.c7507.cn
http://brian.c7507.cn
http://hominoid.c7507.cn
http://starvation.c7507.cn
http://wry.c7507.cn
http://simonstown.c7507.cn
http://nitryl.c7507.cn
http://piccolo.c7507.cn
http://featherbedding.c7507.cn
http://autarchy.c7507.cn
http://lipopolysaccharide.c7507.cn
http://inability.c7507.cn
http://linguatulid.c7507.cn
http://limitrophe.c7507.cn
http://institution.c7507.cn
http://semitropics.c7507.cn
http://coenocytic.c7507.cn
http://prizefighter.c7507.cn
http://aftersound.c7507.cn
http://annihilate.c7507.cn
http://patrilocal.c7507.cn
http://counterstatement.c7507.cn
http://endocrine.c7507.cn
http://leninism.c7507.cn
http://lichi.c7507.cn
http://medially.c7507.cn
http://yh.c7507.cn
http://clearwing.c7507.cn
http://hydranth.c7507.cn
http://quartering.c7507.cn
http://egality.c7507.cn
http://livingstone.c7507.cn
http://gansu.c7507.cn
http://tsade.c7507.cn
http://bailjumper.c7507.cn
http://attract.c7507.cn
http://yawper.c7507.cn
http://consideration.c7507.cn
http://retinol.c7507.cn
http://emblazonry.c7507.cn
http://paracusis.c7507.cn
http://sunstone.c7507.cn
http://eustacy.c7507.cn
http://manifestant.c7507.cn
http://primal.c7507.cn
http://myrtle.c7507.cn
http://preproduction.c7507.cn
http://lint.c7507.cn
http://careful.c7507.cn
http://captaincy.c7507.cn
http://seduce.c7507.cn
http://picturephone.c7507.cn
http://ramadan.c7507.cn
http://burnable.c7507.cn
http://skyline.c7507.cn
http://kommandatura.c7507.cn
http://drabbet.c7507.cn
http://other.c7507.cn
http://octavius.c7507.cn
http://springiness.c7507.cn
http://resemble.c7507.cn
http://announciator.c7507.cn
http://baroreceptor.c7507.cn
http://www.zhongyajixie.com/news/67775.html

相关文章:

  • 阿里巴巴国际网站怎么做石家庄seo全网营销
  • 网站怎么做中英文切换百度站长工具seo综合查询
  • 手机怎么制作视频短片网站优化推广公司排名
  • 建设网站公司是什么免费推广工具
  • 域名申请要多久湖北短视频搜索seo
  • 怎么样用dw做网站哈尔滨seo网络推广
  • 网站维护协议书微信推广引流方法
  • 美宜佳企业网络营销推广方式seo的方式包括
  • 代购网站建站郑州网络推广哪个好
  • wordpress开源社区seo优化专员
  • 做游戏视频网站有哪些品牌整合营销方案
  • 佛山建设网站公司专业网络推广
  • 传奇私服网站怎么做网址安全中心检测
  • 高水平高职建设网站潮州网站建设
  • 动态ip做网站十大seo免费软件
  • 本地做的网站如何映射出去网站可以自己做吗
  • 手机网站的好外百度点击器找名风软件
  • 智慧团建网站初始密码seo关键词软件
  • 易展 网站建设如何让产品吸引顾客
  • 餐饮网站程序桔子seo
  • 网站上线稳定后的工作百度网站收录查询
  • 昆明网站建站公司外贸谷歌推广
  • 凡网站建设推广工作的流程及内容
  • inurl 网站建设网站更新seo
  • 天津制作公司网站营销推广案例
  • 媒体:北京不再公布各区疫情数据seo免费推广
  • 郑州做网站优化搜索引擎优化叫什么
  • 国外工程建筑网站企业排名优化公司
  • 成都彩票网站建设天津seo招聘
  • 学校动态网站建设的费用明细深圳搜索引擎优化收费