Guest User

Untitled

a guest
Aug 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. var text = "Ahoy there matey";
  2. var pattern = /(\w+) (\w+) (\w+)/i;
  3. var result = text.match(pattern);
  4.  
  5. console.log('Full match:', result[0]); // Ahoy there matey
  6. console.log('Word #1:', result[1]); // Ahoy
  7. console.log('Word #2:', result[2]); // there
  8. console.log('Word #3:', result[3]); // matey
Add Comment
Please, Sign In to add comment