Check out example codes for "hoow to match a complete word in ruby?". It will help you in understanding the concepts better.

Code Example 1

p text.scan /\bcat\b/

Learn ReactJs, React Native from akashmittal.com