Linked Questions
24 questions linked to/from How do you search an array for a substring match?
47
votes
5
answers
79k
views
Check if an array of strings contains a substring [duplicate]
I have an array like this:
array = ["123", "456", "#123"]
I want to find the element which contains the substring "#". I tried array.includes("#") ...
0
votes
3
answers
3k
views
Checking for a wildcard match in an array [duplicate]
Using the indexOf function, how can I get a positive result when searching an array for a wildcard card match such as the below? All I am currently getting is a negative result: (-1)
function test() {...
0
votes
3
answers
806
views
How can I find match string in array javascript? [duplicate]
How can I find a match in an array of strings using Javascript? For example:
var str = "https://exmaple.com/u/xxxx?xx=x";
var filter = ["/u","/p"];
if (!str.includes(filter)){
return 1;
}
In the ...
-2
votes
1
answer
559
views
Search Array Elements For Substring and return index [duplicate]
I am trying to search through each element in an Array to find if it contains a substring. If it does I want to have the index returned.
Presently, I am using this code:
function searchString(){
...
0
votes
3
answers
446
views
Javascript array display only the searched item [duplicate]
I would like to know how I can display the item from my array which contains 1 word of the item.
For Example:
My Array values:
[ "Level 3", "Level 4", "Level 5", "Level 6" ]
I search only "5", ...
-1
votes
1
answer
166
views
How to find specific line of data in array [duplicate]
I basiaclly have a block of text that I put into a array , how would i be able to find a specific value and return the full line. something like
array['bob 123'.'joe 112','sam 888']
if (array.contains(...
0
votes
0
answers
185
views
Find all elements in array that contain the search key [duplicate]
Is there a built in method in Typescript that searches a string array and finds all items that contain the search string. e.g.
var myarray = ["apple", "orange", "app"];
var searchKey = "app"
this ...
1
vote
1
answer
46
views
Check if value exist in array even if it is followed by other letters [duplicate]
I have an array with multiples values
let array = ['value othervalue', 'value2 othervalue2']
I want to check :
if (array.includes('value')){
do that
}
It return false because its not 'value' its ...
0
votes
0
answers
157
views
How to use Regular Expression to return the string of an array element that contains the specific word? [duplicate]
How to use Regular Expression to return the string of an array element that contains the word "Netflix"
Here is what I tried:
const arr = [
'Sweet TV - some description',
'MEGOGO - ...
-1
votes
2
answers
76
views
check substring exsit in array Jquery [duplicate]
i need to check a specific string exist in jquery array . For this i write the following code .But it is not working . Please help .
$(document).ready(function() {
var ar = ["color1:white", "...
-2
votes
2
answers
100
views
Excluding Punctuation Marks in JavaScript include method [duplicate]
Is there a better way of checking if a word exists in an array of strings without including Punctuation Marks?
what I have tried,
const sArray=['Lorem','Ipsum','typesetting-','industry.','Ipsum?','has'...
-1
votes
2
answers
82
views
Find partial string in array [duplicate]
var fruits = ["CarPaint.InString.Banana", "CarPaint.InString.Orange", "CarPaint.InString.Apple", "CarPaint.InString.Mango"];
var n = fruits.includes("Mango");
Let's say you don't know whats inside ...
0
votes
0
answers
73
views
Test if array contains specific substring [duplicate]
I'm trying to test if an array contains a specific substring, but I can only get a match if the substring = array value
This is my test code:
var test = ["something", "my-name", "name-test"];
if (...
0
votes
0
answers
68
views
Remove item from array containing text [duplicate]
I have an array called arr[].
I want to remove an array item (so I guess splice) that contains certain text.
So say one of the array items is:
"this is the array item 60894 thank you"
I want to be ...
-1
votes
4
answers
5k
views
filter in typescript/javascript
Consider an array A1 ["text", "test"] and another array A2 ["onetest", "two", "threetext", "fourtext"]
I need to get the result as ["onetest", "threetext", "fourtext"]
This is what I currently have
...