You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varstr="this is a big dog!";// search() 方法应用,查找 str 字符串中的 "i" 字符串所在的位置 str.search(/i/);//返回 2, 即 this 中的 i 的位置 // match() 方法应用,查找 str 字符串中的 "big" 字符串 str.match(/big/);//返回["big"] // replace() 方法应用,把 str 字符串中的 i 字符替换成大写的 I 字符; str.replace(/i/g,"I");// 返回 "thIs Is a bIg dog!" str.replace("i","I");// 返回"thIs is a big dog!" // split() 方法应用,把 str 字符串中的按空格进行分割 str.split(" ");//返回 ["this","","","","is","","","a","","big","","","dog!"]str.split(/\s+/);//返回["this","is","a","big","dog!"]
正则表达式是什么
示例: http://www.cnblogs.com/zxin/archive/2013/01/26/2877765.html
^[\u4e00-\u9fa5]{0,}$
^[A-Za-z0-9]+$
^\w+$ 或 ^\w{3,20}$
^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
^\d{15}|\d{18}$
[1-9][0-9]{4,}
RegExp对象
创建语法:
/pattern/attributes
RegExp 对象修饰符
[abc]
[^abc]
[0-9]
[a-z]
[A-Z]
[a-zA-Z]
/.../
^
$
\s
\S
\d
\D
\w
.
{n}
{n,}
{n,m}
*
{0,}
+
{1,}
?
{0,1}
alert
部分)String 对象与正则表达式
search(reg)
match(reg)
replace(reg,str)
split(reg)
The text was updated successfully, but these errors were encountered: