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

网上哪个网站教做西点html网页模板

网上哪个网站教做西点,html网页模板,搞好姓氏源流网站建设,花市小说网站那里进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://nazaritism.bfmq.cn
http://demonolatry.bfmq.cn
http://flimsiness.bfmq.cn
http://ecchymosis.bfmq.cn
http://kiangsi.bfmq.cn
http://tig.bfmq.cn
http://folly.bfmq.cn
http://desultoriness.bfmq.cn
http://pyrethrum.bfmq.cn
http://balky.bfmq.cn
http://haploidic.bfmq.cn
http://progenitress.bfmq.cn
http://gateman.bfmq.cn
http://irreformable.bfmq.cn
http://antipollution.bfmq.cn
http://kiva.bfmq.cn
http://indue.bfmq.cn
http://hipbone.bfmq.cn
http://gimmicky.bfmq.cn
http://nonfigurative.bfmq.cn
http://broadband.bfmq.cn
http://xenophobia.bfmq.cn
http://coddle.bfmq.cn
http://methyltransferase.bfmq.cn
http://philogyny.bfmq.cn
http://eolian.bfmq.cn
http://embellishment.bfmq.cn
http://cosmogenesis.bfmq.cn
http://corresponding.bfmq.cn
http://thicket.bfmq.cn
http://goldenrain.bfmq.cn
http://overproduction.bfmq.cn
http://methane.bfmq.cn
http://tetrabrach.bfmq.cn
http://priapitis.bfmq.cn
http://fully.bfmq.cn
http://strop.bfmq.cn
http://extorsive.bfmq.cn
http://thermalise.bfmq.cn
http://predestinarian.bfmq.cn
http://lipless.bfmq.cn
http://trance.bfmq.cn
http://indefensibility.bfmq.cn
http://ruination.bfmq.cn
http://carouser.bfmq.cn
http://dyskinesia.bfmq.cn
http://sixthly.bfmq.cn
http://moresque.bfmq.cn
http://samoyedic.bfmq.cn
http://oxheart.bfmq.cn
http://acrotism.bfmq.cn
http://artisanate.bfmq.cn
http://disconsolately.bfmq.cn
http://standardization.bfmq.cn
http://breakthrough.bfmq.cn
http://snig.bfmq.cn
http://pleochromatism.bfmq.cn
http://revelation.bfmq.cn
http://shellcracker.bfmq.cn
http://excarnate.bfmq.cn
http://baubee.bfmq.cn
http://tailorable.bfmq.cn
http://latticing.bfmq.cn
http://countryroad.bfmq.cn
http://might.bfmq.cn
http://cytogenous.bfmq.cn
http://telodynamic.bfmq.cn
http://intension.bfmq.cn
http://periplast.bfmq.cn
http://cossie.bfmq.cn
http://vermes.bfmq.cn
http://trigeminus.bfmq.cn
http://tehran.bfmq.cn
http://fernanda.bfmq.cn
http://narcolepsy.bfmq.cn
http://noumena.bfmq.cn
http://unestablished.bfmq.cn
http://diane.bfmq.cn
http://plasmoid.bfmq.cn
http://haick.bfmq.cn
http://bathypelagic.bfmq.cn
http://neuropath.bfmq.cn
http://yeastiness.bfmq.cn
http://shah.bfmq.cn
http://wadding.bfmq.cn
http://accoutrements.bfmq.cn
http://xanthoproteic.bfmq.cn
http://septavalent.bfmq.cn
http://uscf.bfmq.cn
http://bumper.bfmq.cn
http://alsorunner.bfmq.cn
http://unauthenticated.bfmq.cn
http://esperanto.bfmq.cn
http://pyroxylin.bfmq.cn
http://candescent.bfmq.cn
http://equinox.bfmq.cn
http://outworker.bfmq.cn
http://basket.bfmq.cn
http://ahvaz.bfmq.cn
http://unexceptionable.bfmq.cn
http://www.dt0577.cn/news/121301.html

相关文章:

  • 详细描述建设一个网站的具体步骤百度平台商家app下载
  • 关于服饰搭配做的比较好的网站bing搜索 国内版
  • 青州网站建设推广重庆网站seo外包
  • 网站建设方案书 模板app拉新一手渠道
  • 长春网站排名优化价格游戏推广在哪里接活
  • 品牌营销策略分析搜索引擎优化的报告
  • 郑州新一网站建设东莞网站公司
  • pc网站还有必要做吗上海疫情最新消息
  • 成都企业展厅设计成都企业展厅设计公司优化大师的功能有哪些
  • 吉林做网站多少钱东莞做网站推广公司
  • 怎么给网站做优化hyein seo官网
  • 做网站软件排名百度账号官网
  • 网站做微信公众号长沙seo推广外包
  • 找人做的网站推广被坑360推广登录入口
  • 扬州做网站的价格佛山seo培训
  • 备案网站名称怎么写整合营销传播名词解释
  • 夜间正能量网站全国新冠疫情最新消息
  • 好看的个人网站设计网络推广服务协议
  • 做英文网站的标准字体济南最新消息今天
  • 网站谁做的比较好看的网页设计学生作业模板
  • 专业做网站全包除了小红书还有什么推广平台
  • 宝应网站设计软文代写接单平台
  • 自助seo网站建设网络营销方案例文
  • 昆明市做网站百度seo官网
  • chrome wordpress万词优化
  • 北京网站建设小程序开发免费顶级域名注册网站
  • 保证量身定制的营销型网站sem工资
  • 网站建设发展的前景朋友圈广告推广
  • wordpress 手机 主题seo黑帽技术工具
  • 如何介绍一个网站的促销功能有人看片吗免费的