Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var str = "abla mla atra lala baaaaaaaaba";
- var re = /[a-z]{2,4}/g;
- var matches = str.match(re);
- // var re = new RegExp("\\w+") (same as) /\w+/
- // ^ begin of string or NOT [^a]
- // $ end of string
- // g -> (after ending slash) gives all matches (without g only first one)
- // i -> (after ending slash) ignore case
- // () -> grouping
- // {n} exactly n occurrences of preceding item
- // {n,} n occurrences or more occurrences of preceding item
- // {n,m} n <-> m interval of occurrences of preceding item
- // \w -> [A-Za-z0-9_]
- // \s -> single whitespace
- // \b -> boundary between space and letter (wrap word)
- //var re = /\b\w*[a{3}]+\b/g;
- // * -> 0 or more matches of preceding item
- // + -> 1 or more matches of preceding item
- // ? -> 0 or 1 matches of preceding item
- // . -> 1 any char
- // x|y -> or
Advertisement
Add Comment
Please, Sign In to add comment