Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var text = "Ahoy there matey";
- var pattern = /(\w+) (\w+) (\w+)/i;
- var result = text.match(pattern);
- console.log('Full match:', result[0]); // Ahoy there matey
- console.log('Word #1:', result[1]); // Ahoy
- console.log('Word #2:', result[2]); // there
- console.log('Word #3:', result[3]); // matey
Add Comment
Please, Sign In to add comment