Advertisement
Guest User

Untitled

a guest
May 26th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. //some regular expression
  2. var exp1 = /a/;
  3.  
  4. //some strings
  5. var str1 = 'somestringwithout';
  6. var str2 = 'somestringwitha';
  7.  
  8. //search for pattern
  9. str1.match(exp1); // null
  10. str2.match(exp1); // [ 'a', index: 14, input: 'somestringwitha' ]
  11. exp1.test(str1); // false
  12. exp1.test(str2); // true
  13. exp1.exec(str1); // null
  14. exp1.exec(str2); // [ 'a', index: 14, input: 'somestringwitha' ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement