Advertisement
NubeColectiva

Como Buscar Una Palabra en JavaScript

Mar 30th, 2023 (edited)
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const text = "Hola Crack de la Programación !";
  2. const searchWord = "Crack";
  3.  
  4. function findWord(searchWord, text) {
  5.     return RegExp('\\b'+ searchWord +'\\b').test(text)
  6. }
  7.  
  8. console.log(findWord(searchWord, text));
  9.  
  10. // Output: true
Tags: JavaScript js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement