javascript includes method getting 'hi' and 'high' problem
const multiSearchOr = (text, searchWords) => (
searchWords.some((el) => {
return text.match(new RegExp(el,"i"))
})
)
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["che", "hire"]) //returns true
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["aaa", "hire"]) //returns true
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["che", "zzzz"]) //returns true
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["aaa", "1111"]) //returns false
var str = 'hilly';
var value = str.includes('hi'); //true, even though the word 'hi' isn't found
var value = /\bhi\b/.test(str); //false - 'hi' appears but not as its own word
Also in JavaScript:
- remove object from array javascript
- javascript get width of image
- javascript get text from paragraph
- intval js
- what is jsonwebtoken
- javascript progress of xml http request
- how to find index of max number in js
- get select2 selected value
- how to call function from another js file in react native
- deploy react to aws
- reactjs update state example
- javascript backslash
- pdf to image javascript
- most used events in javascript
- random color in javascript
- javascript queryselector
- button style in jquery datatable
- jquery array compare values
- javascript tracking webcam
- iframe content zoom in and zoom out jquery
- js validate email
- <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(\.well-known/.*)$ $1 [L] RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] </IfModule>
- how to call a function with a button in javascript
- sinh(x)