一 代码
<html><head><title>字符匹配的使用</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><h3>字符匹配的使用</h3><script language="JavaScript"><!--var textString="Mrsoft";var reg_expression =/[A-Z][a-z]soft/;var result=reg_expression.test(textString);document.write("<font size='+1'>匹配结果为:"+result+"<br>");if(result){document.write("在“"+textString+"”中找到了正则表达/[A-Z][a-z]soft/的匹配。<br>");}else{document.write("未找到匹配的模式!");}// --></script><h3>圆点(.)元字符的使用</h3><script language="JavaScript"><!--var textString="明天科技 mingri 有限公司 mr";var reg_expression =/明....m/;var result=reg_expression.test(textString);document.write("<font size='+1'>匹配结果为:"+result+"<br>");if(result){document.write("在“"+textString +"”中找到正则表达式/明....m/的匹配。<br>");}else{document.write("未找到匹配的模式!");}// --></script></body></html>
二 运行效果
字符匹配的使用
匹配结果为:true在“Mrsoft”中找到了正则表达/[A-Z][a-z]soft/的匹配。
圆点(.)元字符的使用
匹配结果为:true在“明天科技 mingri 有限公司 mr”中找到正则表达式/明....m/的匹配。
552

被折叠的 条评论
为什么被折叠?



