- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
正则表达式使用实例(Regular expressions using instances)
正则表达式使用实例(Regular expressions using instances)
Regular expressions use instance 2007-05-24 at 22:06, in JavaScript 1.2 with a powerful RegExp () object that can be used for regular expression matching operations. The test () method can test whether the target object contains matching patterns and returns true or false accordingly.
We can use JavaScript to write the following script to verify the validity of the mail address entered by the user.
Code
html
head
script language= Javascript1.2
- start hiding
Function verifyAddress (obj)
{
Var email = obj.email.value;
Var pattern =
/ ^ ([a-zA-Z0-9_-]) + @ ([a-zA-Z0-9_-]) + (\.[a-zA-Z0-9_-] +);
Flag = pattern.test (email);
If (flag)
{
Alert (Your, email, address, is, correct);
Return true;
}
Else
{
Alert (Please try again!);
Return false;
}
}
Stop / hiding --
/script
/head
body
form onSubmit= return verifyAddress (this)
input name=, email, type=, text
input type= submit
/form
/body
/html
RegExp
This object contains regular expression patterns and flags that indicate how to apply patterns.
Code
Syntax 1 re = /pattern/[flags]
Syntax 2, re = new, RegExp (` pattern , ` flags])
parameter
Re
Option. The name of the variable to be assigned to the regular expression pattern.
Pattern
Option. The regular expression pattern to use. If syntax 1 is used, the / characters are used to separate the schema. If syntax 2 is used, the pattern is raised in quotation marks.
Flags
Optional. If you use syntax 2, you should quote flag in quotation marks. Signs can be used in combination:
Code
G (all the pattern that appear in full text search) Global
I (ignore case) ignore
M (multiline lookup) more line
Sample
The following example creates an object that contains regular expression patterns and associated flags (RE), and demonstrates the use of regular expression objects. In this case, the regular expression object as a result is used in the match method:
Code
Function, MatchDemo ()
{
Var R, re; / / declare variables.
Var s = The, rain, in
您可能关注的文档
- 怎样可以学会做生意(How can you learn to do business).doc
- 怎样处置推销职员背工管理请求 给仍是不给(How to deal with sales staff, back work management, request or not).doc
- 怎样学fpga(How to learn FPGA).doc
- 怎样学习家电维修技术(How to study appliance maintenance technology).doc
- 怎样使句子多样化(How to diversify sentences).doc
- 怎样成为天下五百强的管理发卖总监(How to become the world's top five hundred management sales director).doc
- 怎样才能做出高质量的立体画(How can we make high-quality stereoscopic paintings).doc
- 怎样挑选一把好剪刀(How do you pick a pair of scissors).doc
- 怎样提高高考复习效率(How to improve the efficiency of college entrance examination).doc
- 影调【私家编导课件】([private] courseware director tone).doc
- 歌唱法(Singing method).doc
- 正式场合的着装(Dress up for formal occasions).doc
- 正弦交流电教案(Sinusoidal alternating current lesson plan).doc
- 正数和负数(positive and negative numbers).doc
- 步入商界(Starting Business English).doc
- 此篇韵文 实在了得(This verse really terrible).doc
- 步子沙盘(Pace table).doc
- 步进梁式加热炉压力测量资料1(Pressure measurement data of walking beam reheating furnace 1).doc
- 步进马达正反转控制doc(Stepper motor positive and negative control, doc).doc
- 步里客谈(南宋陈长方)(Step guest talk (Southern Song Dynasty, Chen Changfang)).doc
文档评论(0)