[javascript]
<div>
var re = new RegExp('j.*t')
undefined
var re = new RegExp("j.t");
undefined
re
/j.t/
var re = /j.t/
undefined
re
/j.t/
re.global
false
re.ignoreCase
false
re.multiline
false
var re = new RegExp("j.t")
undefined
re
/j.t/
var re = /j.t/ig;
undefined
re
/j.t/gi
re.ignoreCase
true
re.global
true
re.ignoreCase
true
re.mulreligne
undefined
re.multeline
undefined
re.mulitiline
undefined
re.multiline
false
re.multiline
false
/j.t/.test("javascript");
true
re.test("javascript")
true
/j.t/i.test('javascript');
true
/j.t/.exec("javascript")[0]
"javascript"
/j.t/.exec("javascript","eee")[1]
undefined
var s = new String('HellowJavascriptWorld');
undefined
s
String {0: "H", 1: "e", 2: "l", 3: "l", 4: "o", 5: "w", 6: "J", 7: "a", 8: "v", 9: "a", 10: "s", 11: "c", 12: "r", 13: "i", 14: "p", 15: "t", 16: "W", 17: "o", 18: "r", 19: "l", 20: "d", length: 21, [[PrimitiveValue]]: "HellowJavascriptWorld"}
s.match(/a/);
["a"]
s.match(/a/g);
["a", "a"]
s.match(/a/ig);
["a", "a"]
s.match(/j./ig);
["JavascriptWorld"]
s.match(/j.a/i);
["Java"]
s.match(/j.s/i);
["Javas"]
s.match(/j.c/i);
["Javasc"]
s.match(/a.c/i);
["avasc"]
s.match(/a.c/i);
["avasc"]
s.search(/a.c/i);
7
s.search(/j.c/i);
6
s.search(/j.c/i);
6
s.search(/j.a/i);
6
s.search(/j.a/i);
6
s.replace(/[A-Z]/g,'');
"ellowavascriptorld"
s.replace(/[a-z]/g,'');
"HJW"
s.replace(/[A-Z]/,'');
"ellowJavascriptWorld"
s.replace(/[A-Z]/,'$&');
"_HellowJavascriptWorld"
s.replace(/[A-Z]/g,'$&');
"Hellow_Javascript_World"
s.replace(/([A-Z])/g,'$1');
"Hellow_Javascript_World"
s.replace(/([A-Z])/g,'$1');
"_Hellow_Javascript_World"
var email = morita@yahoo.co.jp
Uncaught SyntaxError: Unexpected token ILLEGAL VM1156:732
email
Uncaught ReferenceError: email is not defined VM2116:2
var email = 'morita@yahoo.co.jp'
undefined
email
"morita@yahoo.co.jp"
var username = /.@/i;
undefined
var username = email.replace(/.@/i);
undefined
var username = email.replace(/.@/i);
undefined
username
"undefinedyahoo.co.jp"
var username = email.replace(/(.)@./,"$1");
undefined
username
"morita"
function replaceCallback(match){return ""+ match.toLowerCase();}
undefined
function replaceCallback(match){return ""+ match.toLowerCase();}
s.replace(/[A-Z]/g,replaceCallback);
"_hellow_javascript_world"
var glob;
undefined
var re = /(.*)@(.*).(.*)/;
undefined
re
/(.*)@(.*).(.*)/
var callback = function(){
glob = arguments;
return arguments[1] + 'at' + arguments[2] + 'dot' + arguments[3];
}
undefined
"moritakenji@yahoo.co.jp".replace(re,callback);
"moritakenjiatyahoo.codotjp"
var callback = function(){
glob = arguments;
return arguments[1] + ' at ' + arguments[2] + ' dot ' + arguments[3];
}
undefined
"moritakenji@yahoo.co.jp".replace(re,callback);
"moritakenji at yahoo.co dot jp"
glob
["moritakenji@yahoo.co.jp", "moritakenji", "yahoo.co", "jp", 0, "moritakenji@yahoo.co.jp"]ß
</div>
var reg = new RegExp('^[0-9]');
reg.test('foo');
false
reg.test('123');
true
var reg = /'^[0-9]'/;
undefined
var reg = /'^[0-9]'/;
function RegExp(){
}
undefined
var reg = /'^[0-9]'/;
reg.constructor;
function RegExp() { [native code] }
var reg = /'^[0-9]'/g;
var reg = /^\s+/;
undefined
reg
/^\s+/
var reg = new RegExp('^\s+');
undefined
var reg = new RegExp('^\s+');
undefined
reg
RegExp {}
var text = 'abc def ghi jkl';
var reg = /(\w+)\s(\w+)/;
reg.exec(text);
["abc def", "abc", "def"]
var reg = /(\w+)\s(\w+)/g;
undefined
reg
/(\w+)\s(\w+)/g
var text = 'abc def ghi jkl';
undefined
reg.exec(text);
["abc def", "abc", "def"]
reg.exec(text);
["ghi jkl", "ghi", "jkl"]
reg.exec(text);
null
var text = 'moritakenji';
var result = text.search(/^kan/g);
result;
-1
var text = 'moritakenji';
var result = text.search(/^moirta/g);
result;
-1
var text = 'moritakenji';
var result = text.search(/^(moirta)/g);
result;
-1
var text = 'abc def ghi jkl';
text.replace(/\s/,',');
"abc,def ghi jkl"
var text = 'abc def ghi jkl';
text.replace(/\s/g,',');
"abc,def,ghi,jkl"
text.replace(/(.)\s/g,',$1');
"ab,cde,fgh,ijkl"
text.replace(/(.)\s/g,function(01m,02m){return ','+ 02m});
Uncaught SyntaxError: Unexpected token ILLEGAL VM50:732
text.replace(/(.)\s/g,function(m0,m1){return ','+ m1});
"ab,cde,fgh,ijkl"
var text = 'abc def ghi jkl';
undefined
text
"abc def ghi jkl"
text.match(/\w/g);
["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
text.match(/(w+)\s/g);
null
text.match(/(w)\s/g);
null
text.match(/(.)\s/g);
["c ", "f ", "i "]
text.match(/(.)\s/g);
["c ", "f ", "i "]
text.match(/([a-z]{,3})\s/g);
null
text.match(/([a-z]{3})\s/g);
["abc ", "def ", "ghi "]
text.match(/([a-z]{1,2})\s/g);
["bc ", "ef ", "hi "]
text.match(/([a-z]{0,1})\s/g);
["c ", "f ", "i "]
text.match(/([a-z]{3})\s/g);
["abc ", "def ", "ghi "]
text.match(/(\w+)\s(\w+)/g);
["abc def", "ghi jkl"]
[/javascript]