正则表达式一
来源:互联网 发布:再生聚酯切片进口数据 编辑:程序博客网 时间:2024/06/16 00:35
MSDN官方文件参考:https://msdn.microsoft.com/zh-cn/library/az24scfc.aspx
eg:
1.判断字符串是否是这样组成的,第一个必须是字母,后面可以是字母、数字、下划线,总长度为5-20
var reg = /^[a-zA-z]\w[4,19]/; (\w 视情况 更换 \s);
reg.test(str);
2.编写一个javascript的函数把url解析为与页面的javascript.location对象相似的实体对象,如:url :'http://www.qq.com/index.html?key1=1&key2=2',最后输出的对象是
- var mylocation = {
- 'protocol':'http',
- 'hostname':'',
- 'pathname':'',
- 'query':''
- }
- var url = 'http://www.qq.com/index.html?key1=1&key2=2';
- var str=url.replace(/http\:\/\//,""); //过滤 http://
- var a=str.split("/"); // 以“/”分割url 存入数组
- mylocation.hostname=a[0];
- var arr=a[1].split("?");
- mylocation.pathname=arr[0];
- mylocation.query=arr[1];
- console.log(mylocation);
0 0
- 正则表达式(一)
- 正则表达式(一)
- 正则表达式一字符
- 正则表达式使用指南一
- 常用正则表达式一
- 正则表达式学习一
- 正则表达式(一)
- 正则表达式解析一
- 正则表达式(一)
- 正则表达式(一)
- 正则表达式(一)
- 正则表达式规则(一)
- 正则表达式学习一
- 正则表达式(一)
- Python正则表达式(一)
- 正则表达式学习(一)
- 正则表达式(一)
- Java正则表达式一
- Android的Handler、MessageQueue、Runnable和Looper的联系(源码选自21版本)
- 路径规划算法初探
- Java Web SSH-Spring Hibernate Struts SSH三大框架整合概述
- (转载)Deep Learning(深度学习)学习笔记整理系列之(八)
- Android官方文档翻译 二 1.Building Your First App
- 正则表达式一
- 建造者模式Builder Pattern
- Norton Internet Security 序列号提取(卡饭)
- 自定义view
- Android连接Tomcat服务器
- uploadifyJcrop
- JVM 垃圾收集器
- LinkedHashMap 源代码
- hdoj 2955 Robberies 【0 1背包】