Mind map
REGULAR EXPRESSION
Map content
REGULAR EXPRESSION
Create REGEXP
- var re1 = new RegExp("abc");
- var re2 = /abc/;
- Use cach 2: khi gap dau phai: var re3 = /abc\+/;
Method
- .test()
- string container match of pattern?
- return true - contain, false - not contain
- console.log(/abc/.test("abcde");
- Kiem tra trong chuoi "abcde" co abc ko?
- //true
- exec()
- return null - not match, obj with info aboutn match - contain
- var match = /\d+/exec("one two 100"); console.log(match); console.log(match.index)
- .match()
- Chn # exec()
- console.log("one two 100".match(/\d+/)); //["100"]
- replace()
- replace part of the string with another string
- console.log("papa".replace("p", "m"));
- .test()
Repeat part of pattern
- put (+) after sth in regexp
- --> repeated more than once
- console.log(/'\d+'/.test("'123'"));
- put (*)
- may occur zero time
- console.log('\d*'/\.test(" '123' ")); //true
- console.log('\d*/\.test(" '' ");
- put ?
- may occur 0 or 1 time
- var neighbor = /neoghbo?r/; console.log(neighbor.test("neighbour")); console.log(neighbor.test("neighbor"));
- put (+) after sth in regexp
Date Type
- Obj type 4 represent date
- Create
- new Date() -> current date and time
- new Date(2016, 12, 9) -> specific time
- feature
- month start at 0 (December is 11)
- Day numbers start at 1
- Unix time
- timestamp store number of millisecond since the start of 1970
- negative number 4 times before 1970
- Create-> new Date(1387407600000)
Pattern (xem anh)
- http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Information
- Description
- Beginner JavaScript Mind Map on REGULAR EXPRESSION, created by Nguyet Huynh on 09/12/2016.
- Created by
- Nguyet Huynh
- Views
- 1
- Rating