Questions tagged [contains]
The "contains" operator/method is used to determine if an entity collection contains an element with a particular property.
contains
349
questions
3449
votes
32
answers
1.3m
views
Case insensitive 'Contains(string)'
Is there a way to make the following return true?
string title = "ASTRINGTOTEST";
title.Contains("string");
There doesn't seem to be an overload that allows me to set the case ...
3586
votes
10
answers
6.9m
views
Does Python have a string 'contains' substring method?
I'm looking for a string.contains or string.indexof method in Python.
I want to do:
if not somestring.contains("blah"):
continue
2653
votes
36
answers
6.7m
views
How do I check if a string contains a specific word?
Consider:
$a = 'How are you?';
if ($a contains 'are')
echo 'true';
Suppose I have the code above, what is the correct way to write the statement if ($a contains 'are')?
655
votes
19
answers
733k
views
Check if multiple strings exist in another string
How can I check if any of the strings in an array exists in another string?
For example:
a = ['a', 'b', 'c']
s = "a123"
if a in s:
print("some of the strings found in s")
else:
...
1407
votes
18
answers
1.8m
views
Determine whether an array contains a value [duplicate]
I need to determine if a value exists in an array.
I am using the following function:
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
if (this[i] == obj)...
329
votes
24
answers
426k
views
How to check if a string contains text from an array of substrings in JavaScript?
Pretty straight forward. In javascript, I need to check if a string contains any substrings held in an array.
635
votes
6
answers
792k
views
Is there a short contains function for lists?
Given a list xs and a value item, how can I check whether xs contains item (i.e., if any of the elements of xs is equal to item)? Is there something like xs.contains(item)?
For performance ...
94
votes
6
answers
56k
views
How do I make jQuery Contains case insensitive, including jQuery 1.8+?
I'm trying to use "contains" case insensitively. I tried using the solution at the following stackoverflow question, but it didn't work:
Is there a case insensitive jQuery :contains selector?
For ...
1017
votes
15
answers
4.5m
views
SQL SELECT WHERE field contains words
I need a select which would return results like this:
SELECT * FROM MyTable WHERE Column1 CONTAINS 'word1 word2 word3'
And I need all results, i.e. this includes strings with 'word2 word3 word1' or '...
299
votes
14
answers
634k
views
Java List.contains(Object with field value equal to x)
I want to check whether a List contains an object that has a field with a certain value. Now, I could use a loop to go through and check, but I was curious if there was anything more code efficient.
...
161
votes
3
answers
157k
views
Complexity of *in* operator in Python
What is the complexity of the in operator in Python? Is it theta(n)?
Is it the same as the following?
def find(L, x):
for e in L:
if e == x:
return True
return False
L is a ...
109
votes
22
answers
477k
views
How do I use LINQ Contains(string[]) instead of Contains(string)
I got one big question.
I got a linq query to put it simply looks like this:
from xx in table
where xx.uid.ToString().Contains(string[])
select xx
The values of the string[] array would be numbers ...
54
votes
15
answers
82k
views
String contains any items in an array (case insensitive)
How can i check if a $string contains any of the items expressed in an array?
$string = 'My nAmE is Tom.';
$array = array("name","tom");
if(contains($string,$array))
{
// do something to say it ...
288
votes
10
answers
431k
views
Search for "does-not-contain" on a DataFrame in pandas
I've done some searching and can't figure out how to filter a dataframe by
df["col"].str.contains(word)
however I'm wondering if there is a way to do the reverse: filter a dataframe by that ...
151
votes
17
answers
275k
views
How to check if a String contains any of some strings
With a String s, to determine if it contains "a" or "b" or "c". Something that is better than checking each individually:
if (s.contains("a")||s.contains("...