返回到:JavaScript对象:JavaScript RegExp 对象
^n量词匹配任何开头为 n 的字符串。
new RegExp("^n")
或者
/^n/
对字符串开头的 “Is” 进行全局搜索:
var str="Is this his";
var patt1=/^Is/g;
DEMO:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web176教程(Web176.com)</title> </head> <body> <script> var str="Is this his"; var patt1=/^Is/g; document.write(str.match(patt1)); </script> </body> </html>