JavaScript if array values exist in a string (similar to regex) array values exist php,array_values exist,javascript array values exists

How can I determine if a string contains one of the values from an array?

For example:

var a = ["abc","def","ghi"];

var s = "jskljfdkljflkjk abc jskfdjklsj";


for(var i=0;i<a.length;i++){
    if(/a[i]/.test(s)) alert(1);
}

This obviously doens't work... I know it's very possible though hahaha

Answer:1
function doesStringContainElementFromArray(str, arr)
{
  for ( var i=0; i<arr.length; i++)
  {
    if ( str.indexOf(arr[i]) != -1 )
      return true;
  }
  return false;
}
Answer:2

Just use the "RegExp" function/constructor (if you really need regexps)

if (RegExp(a[i]).test(a)) {
  alert(1);
}

if you don't, just use .indexOf

if (s.indexOf(a[i]) != -1) {
  alert("a[i]="+a[i]+" is matched in " + s);
}
Answer:3

I'm write this code for show get point from asp button and show the point on the map: <script src="http://maps.googleapis.com/maps/api/js"></script> <script> var myCenter; ...

I'm write this code for show get point from asp button and show the point on the map: <script src="http://maps.googleapis.com/maps/api/js"></script> <script> var myCenter; ...

  1. show halfway point google maps
  2. show point on google map
  3. show north point on google maps
  4. show multiple point on google maps
  5. javascript show point on google map
  6. google show point

The code is: var someVariable; // this variable is declared but not initialised... alert(typeof someVariable); // alerts 'undefined' alert(typeof notDeclared); // also alerts 'undefined' ...

The code is: var someVariable; // this variable is declared but not initialised... alert(typeof someVariable); // alerts 'undefined' alert(typeof notDeclared); // also alerts 'undefined' ...

  1. what does ���� mean
  2. what does smh mean
  3. what does boomer mean
  4. what does ok boomer mean
  5. what does the fox say
  6. what does simp mean
  7. what does sos mean
  8. what does dna stand for
  9. what does noel mean
  10. what does asl mean
  11. what does ig mean
  12. what does gap stand for
  13. what does otp mean
  14. what does uwu mean
  15. what does mean
  16. what does goat mean
  17. what does bomboclaat mean
  18. what does pansexual mean
  19. what does woke mean
  20. what does ion mean

I have the following: while($round < $counter) <select name="picks[]" id="winner">'; echo'<option value="'.$row['team1'].'">'.$team1.'</option>'; echo'<option ...

I have the following: while($round < $counter) <select name="picks[]" id="winner">'; echo'<option value="'.$row['team1'].'">'.$team1.'</option>'; echo'<option ...

  1. javascript value from select
  2. javascript value from input
  3. javascript value from promise
  4. javascript value from form
  5. javascript value from array
  6. javascript value from object
  7. javascript value from json
  8. javascript value from table cell
  9. javascript value from radio button
  10. javascript value from checkbox
  11. javascript value from input field
  12. javascript value from dropdown
  13. javascript value from php
  14. javascript value from string
  15. javascript value from id
  16. javascript value from textarea
  17. javascript value from html
  18. javascript value from key
  19. javascript value from text input
  20. javascript value from function

In my web app, users drag images from their desktop onto the browser window. I then use FileReader's readAsDataURL to display the image in the browser, as I described here. I can then upload the image ...

In my web app, users drag images from their desktop onto the browser window. I then use FileReader's readAsDataURL to display the image in the browser, as I described here. I can then upload the image ...

  1. save todataurl image
  2. save dataurl as image
  3. save data url as image php
  4. php save data uri as image